{"thread":{"id":"23904","subject":"git branch --track to link existing local branch to remote?","startedAt":"2010-05-25T19:40:40Z","lastAt":"2010-05-26T08:46:41Z","messageCount":4,"participants":["skillzero@gmail.com","Björn Steinbrink","Joshua Jensen","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"142294","messageId":"AANLkTinxohzZE6uinzYPIAx3iVjw7afDLsr9MPMUAvHj@mail.gmail.com","threadId":"23904","inReplyTo":null,"subject":"git branch --track to link existing local branch to remote?","fromName":"","fromEmail":"skillzero@gmail.com","sentAt":"2010-05-25T19:40:40Z","receivedAt":"2010-05-25T19:40:40Z","isPatch":false,"sender":{"key":"skillzero@gmail.com","avatar":null},"body":"Is there a way to link a local branch, which already exists, to a\nremote branch without editing the git config file? I create a local\nrepository and committed some changes, created a remote repository,\nadded the remote to the local repository, and then pushed the local\nbranch to the remote. Now the local master points to the same commit\nas origin/master. However, the branches aren't linked in the config\nfile so I can't just do git pull.\n\nI know I can manually edit the config file (as the error message on\ngit pull says), but it seems like 'git branch --track master\norigin/master' should do that automatically, especially if both\nbranches point to the same commit. It currently complains that the\nbranch master already exists and -f doesn't let me replace the current\nbranch. So what I've had to do is create a temp branch, switch to it,\ndo git branch -f --track master origin/master, and then delete the\ntemp branch. Is there a better way?\n"},{"id":"142295","messageId":"20100525195303.GA8174@atjola.homenet","threadId":"23904","inReplyTo":"AANLkTinxohzZE6uinzYPIAx3iVjw7afDLsr9MPMUAvHj@mail.gmail.com","subject":"Re: git branch --track to link existing local branch to remote?","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2010-05-25T19:53:03Z","receivedAt":"2010-05-25T19:53:03Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2010.05.25 12:40:40 -0700, skillzero@gmail.com wrote:\n> However, the branches aren't linked in the config file so I can't just\n> do git pull.\n[...]\n> So what I've had to do is create a temp branch, switch to it, do git\n> branch -f --track master origin/master, and then delete the temp\n> branch. Is there a better way?\n\nWith git v1.7.0 or newer:\ngit branch --set-upstream master origin/master\n\nBjörn\n"},{"id":"142296","messageId":"4BFC2B18.2050904@workspacewhiz.com","threadId":"23904","inReplyTo":"AANLkTinxohzZE6uinzYPIAx3iVjw7afDLsr9MPMUAvHj@mail.gmail.com","subject":"Re: git branch --track to link existing local branch to remote?","fromName":"Joshua Jensen","fromEmail":"jjensen@workspacewhiz.com","sentAt":"2010-05-25T19:55:04Z","receivedAt":"2010-05-25T19:55:04Z","isPatch":false,"sender":{"key":"jjensen@workspacewhiz.com","avatar":"https://avatars.githubusercontent.com/u/111687?v=4"},"body":"skillzero@gmail.com wrote:\n> Is there a way to link a local branch, which already exists, to a\n> remote branch without editing the git config file?\ngit branch --set-upstream\n\nJosh\n"},{"id":"142354","messageId":"72c4f4098dea94e21d44b8f76965ff1cb26eab72.1274863387.git.git@drmicha.warpmail.net","threadId":"23904","inReplyTo":"20100525195303.GA8174@atjola.homenet","subject":"[PATCH] completion: --set-upstream option for git-branch","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-05-26T08:46:41Z","receivedAt":"2010-05-26T08:46:41Z","isPatch":true,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>\n---\nOn that note, I'm still wondering what's wrong with this one ;)\n\n contrib/completion/git-completion.bash |    1 +\n 1 files changed, 1 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 545bd4b..57245a8 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -797,6 +797,7 @@ _git_branch ()\n \t\t__gitcomp \"\n \t\t\t--color --no-color --verbose --abbrev= --no-abbrev\n \t\t\t--track --no-track --contains --merged --no-merged\n+\t\t\t--set-upstream\n \t\t\t\"\n \t\t;;\n \t*)\n-- \n1.7.1.345.g59eb63\n"}]}