I am using the “Integration-Manager” workflow with Git, while using gitolite for permission management. Gitolite has this neat option for easily managing personal user branches in:
refs/personal/USERNAME/USERBRANCHNAME
In our case, these are the only branches to which the developers have write access. This means they are routinely pulling from the “blessed” repository, which is the “master” branch on the “origin” remote, like so:
$ git pull origin master
However, they need to routinely push their work back up to their personal branches, like so:
$ git push origin master:refs/personal/mysuername/mybranchname
Typing those long branch names gets old, really fast, especially for the integrator, who is having to pull routinely from various, long branch names. Most people want to type something simpler, like:
$ git push origin master:mybranchname
So, my question is, “How do I make this easier with shorter names and reduced typos?” Is there some way to create an alias or shortcut for the user’s remote branch? Our integrator would like to be able to create aliases for each of the developers to simplify her commands also.
Also, is it possible to configure git to always pull from one branch and push to a different branch without having to specify the remote and branch names in both cases? This would help our developers, although it would not help our integrator. … I’m familiar with configuring a single default to push and pull from the same remote and branch, but that does not work in this case, since the push and pull branches are different.
Thanks!
Thanks to all for the input and suggestions. Here’s how I got my developers and integrators to use bare
git pushandgit pull:For The Developer
In the simplest integration-manager workflow, as described above, the developer has cloned (
git clone) and is therefore automatically tracking the remote master branch in her local master branch, so all she needs is:To update her local master branch. If she is working in some other branch, then she can update the upstream branch that is is tracking, as Adam suggested:
The tracked branch (origin/master, in this case) will be pulled by default.
Since the default push target is a different branch and not the same name, we cannot take advantage of the push.default being: tracking, current, or matching. Instead, our developer must set the default source:destination refspec for all pushes to a given remote in her .git/config file, like so:
She could also create an alias, like so:
Aliases are very powerful and offer the ultimate flexibility in avoiding keystrokes. 🙂 The above case can be executed with a simple:
For The Integrator
In this simple case, the integrator usually pushes to one place, origin/master. If the push.default is set to matching, tracking, or current, then a bare push will work, like so:
The frequent pull from various personal developer branches is the more difficult case. The integrator can use aliases to simplify the task, like so:
The integrator can also create branches to track the developer’s personal remote branches, like so:
For this to work, the integrator must add personal branches to her fetch list. This can be accomplished by directly editing her .git/config, like so: (I don’t know how to do this with a git-config or any other git command.)
Thanks to all for the help! Hope this helps someone else who uses gitolite and personal branches outside of head-space.
Thanks!
Trevor