Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I undo tracking a remote branch in git?

I've accidentally unhitched my master branch from tracking origin master I think. It used to be that I could run git pull and git push and it would know that I meant git push origin master but now it does not, and I think it's tracking a different branch because git push origin master works fine (everything up to date) and git push tells me it can't fast-forward changes.

Here's what my git branch -a looks like:

ianstormtaylor:nib Storm$ git branch -a
* master
  original
  transforms
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/sizing
  remotes/origin/transforms

Not sure if that remotes/origin/HEAD -> origin/master is the part that is messed up.

I think this all resulted from a git merge origin sizing call when i meant to do git merge sizing (while on master).

Anyone know what's going on and is able to help? I'd just like to get back to the default remote-tracking setup that git clone creates.

like image 971
Ian Storm Taylor Avatar asked Jan 24 '12 22:01

Ian Storm Taylor


People also ask

How do I remove upstream remote branch?

Deleting remote branches To delete a remote branch, you can't use the git branch command. Instead, use the git push command with --delete flag, followed by the name of the branch you want to delete. You also need to specify the remote name ( origin in this case) after git push .

What does tracking a remote branch mean?

Remote-tracking branches are references to the state of remote branches. They're local references that you can't move; Git moves them for you whenever you do any network communication, to make sure they accurately represent the state of the remote repository.


1 Answers

All you need in you git config (do git config -e to edit) is the following:

[remote "origin"]
   fetch = +refs/heads/*:refs/remotes/origin/*
   url = /Users/me/test.git
[branch "master"]
   remote = origin
   merge = refs/heads/master

If it is there, git push from master, will be equivalent to git push origin master

The remotes/origin/HEAD -> origin/master part just says that HEAD of remote origin is master branch ( of origin) and is fine.

like image 134
manojlds Avatar answered Oct 28 '22 19:10

manojlds