Reputation: 318
I currently have 2 symbolic references with master in the name as below
git ls-remote [email protected]:company/project.git master
9547e4ba01d67e1ff3xxxxxd5110eaaf2f48 refs/for/master
06106b7f1005dbb9f1xxxxxxxx456d2be84346c refs/heads/master
How do I remove or rename the refs/for/master so the ls-remote command only gives one result like so -
git ls-remote [email protected]:company/project.git master
06106b7f1005dbb9f1xxxxxxxx456d2be84346c refs/heads/master
Upvotes: 2
Views: 1635
Reputation:
If you want to remove the refs/for/master
reference, just delete it from the remote (using one of the following):
git push [email protected]:company/project.git :refs/for/master
git push [email protected]:company/project.git --delete for/master
This is one way you can rename it, though it's significantly more work. First, you'll need to fetch the object that refs/for/master
refers to. Only way I know how is to edit your repo's .git/config
to fetch it.
For convenience, let's say that you add [email protected]:company/project.git
as a remote called origin
to your local repo:
git remote add origin [email protected]:company/project.git
Then let's also say that you set up your fetch
configuration in your local clone's .git/config
file to be the following:
[remote "origin"]
url = [email protected]:company/project.git
fetch = refs/for/*:refs/remotes/origin/for/*
Then once you git fetch origin
, you can rename the reference to something else and push it again (you'll still need to delete the old reference though):
git push origin :refs/for/master origin/for/master:for/master
:refs/for/master
deletes the old reference, and origin/for/master:for/master
pushes the old copy of that reference as a new remote reference for/master
.
You can read more about fetch
refspec configuration for remote repos in chapter 9.5 Git Internals - The Refspec of the FREE online Pro Git book.
Upvotes: 3