Archive for the ‘bash’ Tag

Git hints

Here are some hints I find very useful for working with git.

More colour

To get a colourful output in your terminal.

$ git config --global color.branch auto
$ git config --global color.status auto
$ git config --global color.diff true

Merging

For merging I like to use the program `meld`. Add any merge tool you want, such as kdiff3 or xxdiff.

$ git config --global merge.tool meld

For conflicts, you can solve the mess, with your favourite merge program.

$ git mergetool

meld

Checking the logs

Shows the commit log like `git log` including a listing of which files had modifications in a particular commit.

$ git whatchanged

Reset a file to an old revision

Overwrite the file `foobar` with the third last revision of `foobar`.

$ git show HEAD~3:foobar > foobar

Writing a hook

Remove all compiled python files (pyc) before a commit start. To activate a hook you have to make the hook you want in `.git/hooks/` executable.

$ echo "find -name '*.pyc' -delete" >> .git/hooks/pre-commit
$ chmod u+x .git/hooks/pre-commit

Exporting

Create a clean repository export to a folder `foo` in a compressed archive.

$ git archive --format=tar --prefix=foo/ HEAD | gzip -c > foo.tar.gz

That’s not so handy like in svn, I know. Maybe you want to use rsync instead?

$ rsync --exclude='.git'

Blame with GUI

You must install the git-gui package for using it.

$ git gui blame file

git-gui-blame