threads / discuss / 21426

Tracking a remote branch in git

Subject: Tracking a remote branch in git

## tl;dr

2 messages between Oct 29, 2009 and Oct 30, 2009.

replies: 1people: 2as markdown or json

Sips· Oct 29, 2009, 19:45 UTC · lore

Hello everyone. My git setup is as follows:

One local repository residing at D:\Dev\ProjectName One remote repository residing at W:\ProjectName

W is actually a removable disk.

Now, both repositories are connected through remotes. For example, git remote -v in the local repository gives:

storengo W:\ProjectName (fetch) storengo W:\ProjectName (push)

The same command in the remote repository gives:

origin D:\Dev\ProjectName (fetch) origin D:\Dev\ProjectName (push)

Obviously, when I am in the master branch, I can synchronize repositories between each other through git push and git pull.

Then I created a branch in the repository on the removable drive W and named it newfeature. The question is: How can I work with this branch on the local repository as well? I mean, I need the same 'relationship' between branches as in case of the master branch.

I tried the following command on the local repository (which was checked out to the master branch at that time):

git branch --track newfeature storengo/newfeature,
but received an error fatal: Not a valid object name: 'storengo/newfeature'.

With this command I was hoping to create a local branch which would be 'connected' to the same remote branch. As I've said, no luck there. Strangely, the following command works without errors:

git branch --track newfeature storengo/master.

I mean, I am able to track the master branch from the remote repository. Why can't I track some other branch as well? Any ideas what I'm doing wrong?

Thanks, Kirill

-- 
View this message in context: http://www.nabble.com/Tracking-a-remote-branch-in-git-tp26119537p26119537.html
Sent from the git mailing list archive at Nabble.com.
Tim Mazid· Oct 30, 2009, 00:26 UTC · re: Sips · lore

Re: Tracking a remote branch in git

Sips wrote:
Show 12 quoted lines
> 
> Then I created a branch in the repository on the removable drive W and
> named it newfeature. The question is: How can I work with this branch on
> the local repository as well? I mean, I need the same 'relationship'
> between branches as in case of the master branch.
> 
> ...
> 
> I mean, I am able to track the master branch from the remote repository.
> Why can't I track some other branch as well? Any ideas what I'm doing
> wrong?
> 

Have you tried doing 'git fetch'? That should get and track all new remote branches automatically.

Once you have a remote branch, if you've deleted the local branch, you can just do 'git branch LOCAL REMOTE', and that should set up a tracking branch.

If this doesn't work for you, check your git version with 'git --version'. It works for v1.6.5.2.

Good luck, Tim.

-- 
View this message in context: http://www.nabble.com/Tracking-a-remote-branch-in-git-tp26119537p26123156.html
Sent from the git mailing list archive at Nabble.com.

← back to recent threads