How to undo remote branch tracking in git?

I accidentally tracked my main branch from tracking the source of the original, I think. I used to be able to run git pull and git push , and he would know that I had in mind git push origin master , but now that’s not the case, and I think it is tracking another branch because git push origin master works fine ( everything is up to date) and git push tells me that it cannot speed up transitions.

Here's my git branch -a :

 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 this remotes/origin/HEAD -> origin/master is the part that is messed up.

I think all this was caused by calling git merge origin sizing when I wanted to do git merge sizing (for now on the main).

Does anyone know what is happening and can help? I would just like to go back to the default remote tracking setting that git clone creates.

+4
source share
4 answers

All you need is git config (do git config -e for editing):

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

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

The remotes/origin/HEAD -> origin/master simply says that the HEAD of the remote source is the main branch (from the source) and is wonderful.

+3
source

This has happened to me several times - and so far I’m not sure for sure that I do not believe in it because of the mistake you made. Rather, it’s just that git pull is a shortcut for the most recent remote branch, and he forgot what the last branch is.

Running git pull origin master usually updates the settings and resets everything.

+1
source

Suppose you can edit the .git / config file or set the configuration with

 git config branch.master.remote origin git config branch.master.merge refs/heads/master 

Alternatively, recreate the main branch using the -t option ( --tracking )

Both should result in a section similar to this in your .git/config :

 [branch "master"] remote = origin merge = refs/heads/master 
+1
source

you can use

git branch --set-upstream my_branch origin / my_branch

As an alternative

git push -u origin my_branch

See Git: why do --set-upstream all the time? for more details.

+1
source

Source: https://habr.com/ru/post/1392801/


All Articles