Git

Git hacks

Simple note of different usable hacks for everyday work with Git

1 min read
By prox
Git hacks

Simple note of different usable hacks for everyday work with Git.

Save repo credentials to save some time while push/pull changes
user@host:~/your/repo/path$ git config credential.helper store
Use GPG sign commits

How to generate GPG key? Read here

user@host:~/your/repo/path$ gpg2 --list-secret-keys --keyid-format LONG <your_email>
user@host:~/your/repo/path$ git config --global user.signingkey <here_is_key_id>
user@host:~/your/repo/path$ git config --global gpg.program gpg2

To sign commit:

user@host:~/your/repo/path$ git commit -S -a -m "commit_comment"

In case of error gpg: signing failed: Inappropriate ioctl for device try to use this command:

export GPG_TTY=$(tty)

Auto sign commits

If you don't want to type the -S flag every time you commit, you can tell Git
to sign your commits automatically:

$ git config --global commit.gpgsign true
See the differences between current version and previous

Difference between current version and previous commit

# Linux
git diff @^
# Windows
git diff @~

Difference between current version and specific commit:

git diff commit_id HEAD

Diff could be used with tags also:

git diff v1.01 HEAD