Git commands that I mostly use

I know there are plenty of Git cheat sheets on the web but this is not one of them. I just want to give a sense to rookie developers which Git commands they probably need in real world scenarios. Even so, I largely use IDE’s Git integration.

git status

git add README.md

git add .

git commit -m “First Command”

git log
(shows commits)

clear

git hist

git diff

git diff {commit ID} HEAD

git diff {branch name} master

git difftool

Merge types:
fast-forward
(when no additional new work on parent(master) branch, (can be disabled but mostly used)),
automatic
(non-conflicting),
manual
(all merge conflicts must be resolved)

HEAD is last commit of the branch, but can manually move somewhere else

git branch -a

git checkout -b {new branch name}

git checkout {branch name}

git merge {branch name}

cat {file name}
(while merging to see conflicts)

in the .gitignore file, we put the file extensions we want git to ignore

git tag

git tag — list

git tag -d {tag name} -m “Message”

git stash

git stash list

git stash pop

git reset {commit ID} — soft
(for time travel between commits, instead of soft you can use mixed or hard as well)

git reflog
(shows actions in repository)

git remote -v
(shows remote repository)

git clone {remote repository url}

git clone {remote repository url} {folder name}
(If we do not give the file name, it will directly name it just the same as repository)

git fetch origin master
(someone else made a change and pushed to the remote, I fetch it from there, but I did not merge yet, I just got the information)

git pull origin master

git push origin master

git branch -d {local branch name}
(use -D for force delete)

git push origin — delete {remote branch name}