Stoppt die Vorratsdatenspeicherung! Jetzt klicken & handeln!
niemueller.de::home niemueller.de
Open Software. Open Knowledge.




 

Tim's WebLog


Setup git tracking branch for existing branch

Something that I did many web searches is how to setup up tracking of a remote git branch for an existing local branch. That regularly happens for example if I start with a local topic branch, and then push it to the central repository. Now, git does neither automatically setup that this (new) remote branch should be tracked for the local branch nor did I find a convenient command or argument to do so. So here is what is required, assuming that the remote repository is named origin, the local branch is topicbr, and the remote branch is timn/topicbr, and you are in the local git repository:

git config branch.topicbr.remote origin
git config branch.topicbr.merge refs/heads/timn/topicbr
.
It's that easy and now I have a place to look it up next time I need it...

Comments for this posting

Easier way

I have learned that there is a better and easier way to do this from A few git tips you didn't know about:
Simply push with git push -u origin branch and you're set. You can do this at any time, not only on the initial push and also if you already set a different upstream! Most people will also want to set git config --global push.default tracking to have git push only push the current branch, and not all that have the same name on the remote.





Top 5 Pages
Wiki
WebLog
SquidGuard Webmin Module
Network Utilities Webmin Module
IPtables Webmin Module


Palm Software
UniMatrix UniMensa UniSorter
UniChat OHS Mobile Onager


My Bookshelf




Valid XHTML 1.1!

RSS Copyright © 2000-2009 by Tim Niemueller