git branch --track to link existing local branch to remote?
- From
- skillzero@gmail.com <skillzero@gmail.com>
- Date
- May 25, 2010, 19:40 UTC
- Message-ID
- <AANLkTinxohzZE6uinzYPIAx3iVjw7afDLsr9MPMUAvHj@mail.gmail.com>
Is there a way to link a local branch, which already exists, to a remote branch without editing the git config file? I create a local repository and committed some changes, created a remote repository, added the remote to the local repository, and then pushed the local branch to the remote. Now the local master points to the same commit as origin/master. However, the branches aren't linked in the config file so I can't just do git pull.
I know I can manually edit the config file (as the error message on git pull says), but it seems like 'git branch --track master origin/master' should do that automatically, especially if both branches point to the same commit. It currently complains that the branch master already exists and -f doesn't let me replace the current branch. So what I've had to do is create a temp branch, switch to it, do git branch -f --track master origin/master, and then delete the temp branch. Is there a better way?