General git tips

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the git category.

Last Updated: 2024-03-02

Get a git diff with just the file-names

git diff --name-only

Get a diff of files just with the last common commit

This is useful if you have an old PR that haven't had master merged in lately.

git diff master...topic

This will only show commits A,B,C here

      A---B---C topic
     /
D---E---F---G master

By contrast, wwo dots is the default in git diff. That is, if you do:

git diff master topic
# what you’ll get is the same as if you asked for:
git diff master..topic

Then you'll get output the difference from G to C (i.e. with effects of F and G).

Resources

https://matthew-brett.github.io/pydagogue/git_diff_dots.html