Fun with Git

A bunch of entertaining git tricks and reminders for myself.

Configure your user name

For the current repository only.

git config ''
git config 'Max Mustermann'

Rename the author in all previous commits

When you start a project not caring about user names and emails, you can get into trouble once you want to publish it. :)

git filter-branch --commit-filter 'GIT_AUTHOR_NAME="Gaga" git-commit-tree "$@"'

Interesting variables to update:

You shouldn't do this when these commits are already otherwise published. (No, I don't know what will happen.)

Git with server-side repository

Make a bare-bones repo

On the server side, create a bare-bones repository (without working copy) containing your project.

Option A: make an empty bare-bones repo
mkdir -p repos/proj.git
cd repos/proj.git
git init --bare
Option B: from a clone
mkdir repos
cd repos
git clone --bare $ORIGINALREPO proj.git

Hook up client and server

Using SSH on the server

This is my strong preference for personal projects.

If you have a machine with a shared ssh account, you can also easily use that with the ssh protocol, e.g. ssh://username@hostname/full/path/to/repo.git or username@hostname:path/relative/to/homedir/repo.git. (Note: No ssh:// prefix when using relative paths.)

git remote add origin ssh://username@hostname/full/path/to/repo.git
git push  # works with an empty repo on server side.
Using git daemon on the server

Allow the repository to be exported by git daemon:

touch repos proj.git/git-daemon-export-ok

Run daemon and allow pushes.

git daemon --base-path=repos --enable=receive-pack

On the client side, clone the repository:

git clone git://$HOSTNAME/proj
cd proj
# Modify, commit
git push

Open source / Work workflow

This is big, so it's on a separate page.