Question

Dans mon repo actuel, j'ai la sortie suivante:

$ git branch -a
* master
  remotes/origin/master
  remotes/public/master

Je veux supprimer de la liste remotes/public/master de branche:

$ git branch -d remotes/public/master
error: branch 'remotes/public/master' not found.

En outre, la sortie est étrange git remote, car il ne liste pas public:

$ git remote show 
origin

Comment puis-je supprimer 'remotes / public / maître' de la liste de succursales?

Mise à jour, essayé la commande git push:

$ git push public :master
fatal: 'public' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Était-ce utile?

La solution

Vous pourriez avoir besoin d'un nettoyage

git gc --prune=now

ou vous pourriez avoir besoin d'un pruneau

git remote prune public
  

élaguer

     

supprime toutes les branches de suivi rassis sous . Ces branches périmées ont déjà été retirés du dépôt distant référencé par , mais sont toujours disponibles sur place dans « remotes / ».

     

Avec l'option --dry-run, rapport quelles branches seront élagués, mais ne pas réellement les élaguer.

Cependant, il semble que ces auraient dû être nettoyé plus tôt avec

git remote rm public 
  

rm

     

Retirez le nom distant . Toutes les branches de suivi à distance et les paramètres de configuration de la télécommande              sont supprimés.

Il est peut-être vous la main modifié votre fichier de configuration et cela ne se produit pas, ou si vous avez des problèmes de privilège.

Peut-être que courir à nouveau et voir ce qui se passe.

Conseils Contexte

Si vous jetez un coup d'œil dans les journaux de révision , vous remarquerez que je suggère des techniques plus « correctes », qui pour une raison quelconque ne voulait pas travailler sur leur dépôt.

Je me doutais bien l'OP avait fait quelque chose qui a laissé leur arbre dans un état incohérent qui a causé à se comporter un peu étrange, et était nécessaire pour git gc réparer la gauche derrière cochonneries.

Habituellement est suffisante pour git branch -rd origin/badbranch nuking une branche de suivi local, ou pour nuking une git push origin :badbranch branche à distance, et habituellement vous allez jamais devez appeler <=>

Autres conseils

Tout ce que vous devez faire est de

git fetch -p

Il enlèvera toutes vos branches locales qui sont à distance supprimés.

Si vous êtes sur git 1.8.5+ vous pouvez définir cela automatiquement

git config fetch.prune true

ou

git config --global fetch.prune true
git push public :master

Ce supprimerait a souligné la branche à distance nommé comme Kent Fredric master sur.

Pour la liste des branches de suivi à distance:

git branch -r

Pour supprimer une branche de suivi à distance:

git branch -rd public/master

Tout ce que vous devez faire est de

$ git branch -rd origin/whatever 

Il est aussi simple que cela. Il n'y a aucune raison d'appeler un gc ici.

git gc --prune=now is not what you want.

git remote prune public

or git remote prune origin # if thats the the remote source

is what you want

The accepted answer didn't work for me when the ref was packed. This does however:

$ git remote add public http://anything.com/bogus.git
$ git remote rm public

In my case I was trying to delete entries that were saved in .git/packed-refs. You can edit this plain text file and delete entries from it that git br -D doesn't know how to touch (At least in ver 1.7.9.5).

I found this solution here: https://stackoverflow.com/a/11050880/1695680

git push origin --delete <branch name>

Referenced from: http://www.gitguys.com/topics/adding-and-removing-remote-branches/

I had a similar problem. None of the answers helped. In my case I had two removed remote repositories showing up permanently.

My last idea was to remove all references to it by hand.

Lets say the repository is called “Repo”. I did:

find .git -name Repo

and deleted the corresponding files and directories

grep Repo -r .git

This found some text files in which I removed the corresponding lines. Now, everything seems to be fine.

Usually you should leave this job to git.

I didn't know about git branch -rd, so the way I have solved issues like this for myself is to treat my repo as a remote repo and do a remote delete. git push . :refs/remotes/public/master. If the other ways don't work and you have some weird reference you want to get rid of, this raw way is surefire. It gives you the exact precision to remove (or create!) any kind of reference.

Only slightly related, but still might be helpful in the same situation as we had - we use a network file share for our remote repository. Last week things were working, this week we were getting the error "Remote origin did not advertise Ref for branch refs/heads/master. This Ref may not exist in the remote or may be hidden by permission settings"

But we believed nothing had been done to corrupt things. The NFS does snapshots so I reviewed each "previous version" and saw that three days ago, the size in MB of the repository had gone from 282MB to 33MB, and about 1,403 new files and 300 folders now existed. I queried my co-workers and one had tried to do a push that day - then cancelled it.

I used the NFS "Restore" functionality to restore it to just before that date and now everythings working fine again. I did try the prune previously, didnt seem to help. Maybe the harsher cleanups would have worked.

Hope this might help someone else one day!

Jay

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top