Living document with my own personal tips and tricks for using git. I will update this periodically as I find things.
~/.gitconfig, you can add a section for aliases.
These enable you to add quick shortcuts when using git.
You can quickly add an alias for a lot of the other tips here.
For example, here is a snippet of my personal
[alias] st = status co = checkout chadoc = diff master --name-only **/*.adoc
This enables me to
git co for checkout and
git st for status instead of writing the full command.
The latter example is a shortcut for seeing which AsciiDoc files are different on my current branch from
This enables very quick opening of these files in Vim with
:args `git chadoc` or
vim $(git chadoc) from a shell.
You can use
git diff to compare changes between branches.
With no arguments (i.e.
git diff), it will output the diff for all unstaged changes.
git diff --name-only
This shows only the names of the files with changes.
git diff src
This would show all the changes in the
git diff master
Assuming there is a branch named
master, this would show the changes between
git diff master HEAD
Equivalent to previous.
git diff HEAD master
Reverse of previous. i.e. additions appear as removals and vice-versa.
git diff master --name-only
Shows only the names of the files with changes.
git diff **/*.adoc
Only shows diff for files ending with
git diff master **/*.adoc --name-only
Shows the names of files changed between
master, but limited to
vim $(git diff master **/*.adoc --name-only)
.adoc files that have been changed between
master in Vim.
Note that trying to pipe into
xargscreates other issues. While you can handle
stdinproperly by using the
-ooption, Vim itself does not seem to run your
.vimrcin this mode.
:args `git diff master **/*.adoc --name-only`
Same as above but for use if you’re already inside Vim. Note the backticks.