Menu

One neat trick to avoid sending patches

Imagine you have a couple of local commits, and you’re going on leave tomorrow. You can’t push the code, because the build just turned red. What do you? E-mail patches to your pair? Push on a branch?

But there’s another alternative.

Git is a distributed version control system, but we hardly ever make use of the “distributed” nature of Git. You can share code with your pair directly. There is a package called git-daemon which comes bundled with Git. Here’s how you can use it:

Go to the directory one level above your repository and run:

git daemon --base-path=. --informative-errors --verbose --export-all

This will serve all git repositories in the current directory. Your pair can then pull code from you directly. E.g. git pull --rebase git://10.0.2.2/my-repo

One thing to keep in mind though: Git daemon does not have any authentication. DO NOT use this when connected to insecure networks. As long as you’re on a closed, secure LAN, you should be fine. And terminate the daemon as soon as you’re done.

Here’s a small script that will also print out your IP so that you can share it easily: