Git has become probably the most popular source-control system today, and if you're new to it, or don't use it very often, there are some things you might want to do which seem simple, but you just can't remember or work out the required command.
I think git is an unpleasantly inconsistent collection of tools and commands which disappointingly failed to learn from the disparate and sometimes conflicting options to other command-line utilities (for example, does -n mean "add line numbers to the output" [grep, cat] or does it mean "just do a dummy run; change nothing" [rsync, rename], or does it mean "display IP addresses and port numbers instead of host names and protocol names" [netstat, iptables]?). Linus had the opportunity to create a new family of tools which behaved in a way people could understand and remember, but he probably just never used DEC VMS and therefore didn't realise there was a better way of doing things than how Unix does it.
So, guides like this are necessary. This is a summary of things you are likely to want to do with git, and how to do them, for the times when you can't remember, have never needed to do them before, or are simply baffled by the inconsistency of how git works.
git status
git show --name-only <commit reference>
git show --name-status <commit reference>
git show --name-only <commit reference>..
git show --name-status <commit reference>..
git log --follow <path to file>
git log <commit reference>..
git log <other branch name>
git show <commit reference>
git diff <commit reference 1> <commit reference 2> <path to file>
or
git diff <commit reference 1>..<commit reference 2> <path to file>
git diff <branch name 1>: <branch name 2>: <path to file>
git diff <branch name 1>: <branch name 2>: --name-status
git show <branch name>:<path to file>
git show <commit reference>:<path to file>
git diff <branch name 1>: <branch name 2>:
git diff <commit reference 1> <commit reference 2>
git diff --name-only --diff-filter=U
git diff --name-status --diff-filter=U
git diff --diff-filter=U
Go up
Return to main index.