Previous Entry Share Next Entry
Anyone out there know git? How do I fast-forward other tracking branches?
blaisepascal
I want to streamline my git usage in a very common case I'm working with.

We are working with the model of a single remote repository that all of us use. We branch for new features and reintegrate into a trunk branch. Our workflow is that we should integrate from trunk into our working branches when other features are integrated into the trunk.

As such, it's not uncommon for us to do:
(branch) $ git commit -a -m"blah blah blah"
(branch) $ git fetch  # origin/trunk is updated
(branch) $ git checkout trunk
(trunk) $ git pull  # trunk is fast-forwarded to current version of origin/trunk.
(trunk) $ git checkout branch
(branch) $ git merge trunk


I don't like the "git checkout trunk/git pull/git checkout branch" cycle. It's usually combined with my IDE complaining that all my files have changed on disk, and should it reload them. For both checkouts. And the pull. And the merge. The merge is unavoidable, but because of how git works, it should be able to do the fast-forward on trunk without actually needing to switch to it.

But I don't know the command, and my google-foo has failed me on this. Anyone know how?

  • 1
I just spoke to a friend at work, who suggested something like this:

(branch) $ git commit...
(branch) $ git pull origin trunk

There's also a way to set it up so that (branch) pulls from origin/trunk whenever you don't bother supplying a parameter, which is probably documented in the docs for pull.

(branch) is already configured so that it pulls from origin/branch whenever I don't bother supplying a parameter, which is what I want, in general. I definitely want (branch) to be configured so that it pushes to origin/branch whenever I don't bother supplying a parameter.

I also asked on StackOverflow.com, and got the suggestion that instead of pulling, I should be using fetch and merge, and that I don't need to actually update my local trunk in this case. So the 6 commands simplify to:

(branch) $ git commit...
(branch) $ git fetch
(branch) $ git merge origin/trunk

thus avoiding all of the branch switching and IDE reloads except those caused by the actual merge of interest.

I haven't had a chance to try it yet, but I will.

pull is basically a fetch plus a merge. I think you can do it all with just git pull [origin trunk] from the branch.

  • 1
?

Log in

No account? Create an account