git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git branch --track to link existing local branch to remote?
@ 2010-05-25 19:40 skillzero
  2010-05-25 19:53 ` Björn Steinbrink
  2010-05-25 19:55 ` git branch --track to link existing local branch to remote? Joshua Jensen
  0 siblings, 2 replies; 4+ messages in thread
From: skillzero @ 2010-05-25 19:40 UTC (permalink / raw)
  To: Git Mailing List

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?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: git branch --track to link existing local branch to remote?
  2010-05-25 19:40 git branch --track to link existing local branch to remote? skillzero
@ 2010-05-25 19:53 ` Björn Steinbrink
  2010-05-26  8:46   ` [PATCH] completion: --set-upstream option for git-branch Michael J Gruber
  2010-05-25 19:55 ` git branch --track to link existing local branch to remote? Joshua Jensen
  1 sibling, 1 reply; 4+ messages in thread
From: Björn Steinbrink @ 2010-05-25 19:53 UTC (permalink / raw)
  To: skillzero; +Cc: Git Mailing List

On 2010.05.25 12:40:40 -0700, skillzero@gmail.com wrote:
> However, the branches aren't linked in the config file so I can't just
> do git pull.
[...]
> 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?

With git v1.7.0 or newer:
git branch --set-upstream master origin/master

Björn

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: git branch --track to link existing local branch to remote?
  2010-05-25 19:40 git branch --track to link existing local branch to remote? skillzero
  2010-05-25 19:53 ` Björn Steinbrink
@ 2010-05-25 19:55 ` Joshua Jensen
  1 sibling, 0 replies; 4+ messages in thread
From: Joshua Jensen @ 2010-05-25 19:55 UTC (permalink / raw)
  To: skillzero; +Cc: Git Mailing List

skillzero@gmail.com wrote:
> Is there a way to link a local branch, which already exists, to a
> remote branch without editing the git config file?
git branch --set-upstream

Josh

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] completion: --set-upstream option for git-branch
  2010-05-25 19:53 ` Björn Steinbrink
@ 2010-05-26  8:46   ` Michael J Gruber
  0 siblings, 0 replies; 4+ messages in thread
From: Michael J Gruber @ 2010-05-26  8:46 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Shawn O. Pearce

Signed-off-by: Michael J Gruber <git@drmicha.warpmail.net>
---
On that note, I'm still wondering what's wrong with this one ;)

 contrib/completion/git-completion.bash |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 545bd4b..57245a8 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -797,6 +797,7 @@ _git_branch ()
 		__gitcomp "
 			--color --no-color --verbose --abbrev= --no-abbrev
 			--track --no-track --contains --merged --no-merged
+			--set-upstream
 			"
 		;;
 	*)
-- 
1.7.1.345.g59eb63

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-05-26  8:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-25 19:40 git branch --track to link existing local branch to remote? skillzero
2010-05-25 19:53 ` Björn Steinbrink
2010-05-26  8:46   ` [PATCH] completion: --set-upstream option for git-branch Michael J Gruber
2010-05-25 19:55 ` git branch --track to link existing local branch to remote? Joshua Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).