Home > Blockchain >  Change the meaning of origin in git
Change the meaning of origin in git

Time:09-30

We just changed the default branch name in our GitLab repository from qa to main. We left the old branch intact.

Before, git log origin.. would show me the differences between my current branch and qa. It still does that - it shows me the difference between my branch and the last commit to qa (not main, which is what we want). (This is after a fetch.)

git show origin/qa and git show origin display the same commit.

grep qa .git/config returns nothing.

git remote -v just shows the (correct) repository location.

How can we change the meaning of the origin reference?

CodePudding user response:

Use git remote set-head. The name origin, treated as a revision, is shorthand for origin/HEAD, which you can write out explicitly, and origin/HEAD means what you set with git remote set-head. But I recommend not using origin/HEAD at all, neither with nor without the shorthand. Write out the actual name you mean, such as origin/qa, every time, so that it is not ambiguous.

  • Related