I'm pretty new to git, can anyone please help me out.
for the HEAD
syntax
HEAD
is the latest commit in a branchHEAD~N
is the nth older commit from HEAD
git diff HEAD
will show you the difference between the current content and the most recent commit
this is especially helpful if you have staged content (git add
ed, but not yet commit
ed) and you are also interested in the unstaged difference git diff
(which will show you only the difference between the staged commit state and changes on top of it)
git diff HEAD~1..HEAD
will show you the difference between the most recent and its previous on the current branch, ignoring any current differences
this is useful for comparing ranges of previous commits (along with syntax like git reset --soft HEAD~N
, which will bring the branch's HEAD
to ~N
discarding the intermediate commits, but leaving them staged as if you had used git add
)
git diff HEAD..HEAD~1
shows you the reverse of HEAD~1..HEAD
this is usually a mistake and just a source of confusion