Useful Git Command Note (Uncompleted)
I’m taking this note to avoid googling them each time I wanted to use them.
git reset HEAD <file>
Show the difference between that COMMIT's ancestor and the COMMIT
git log --graph --oneline --decorate --date=relative --all
graph enables you to view different branches
oneline will format git log into one line output
decorate adds some highlights to branch names
all helps you view all branches.
I’d suggest you to rebase when git pull, this will prevent “Merge conflict” from happening. Honestly, I don’t like to handle conflicts manually.
git pull --rebase
If you want to know the difference between
git pull and
git pull --rebase, check this: Difference between git pull and git pull –rebase. The difference between
git merge and
git rebase can also be found here: What’s the difference between ‘git merge’ and ‘git rebase’?.
git rebase --interactive HEAD~N
Needless to say, it you want to squash serveral commits into one commit, this helps a lot. More detailed instructions can be found here: squashing commits with rebase.