I have a git repo with tens of remotes which have been merged into master. I can delete these remotes one at a time by using:
git push --delete origin myBranch-1234
然而,对于所有的遥控器来说,这是一个缓慢而乏味的过程:
git branch -r --merged | grep origin | grep -v master | xargs git push origin --delete
git branch -r --merged
列出所有合并的远程。
grep origin
告诉命令要包含原点。
grep -v master
告诉命令排除 master。
xargs git push origin --delete
tells the command to delete the list of remotes.
总之,我希望这个程序能够收集所有合并的远程并删除它们。
当我运行上述命令时,对于每个合并的远程,我收到如下命令;
error: unable to delete 'origin/myBranch-1234': remote ref does not exist
error: unable to delete 'origin/myBranch-1235': remote ref does not exist
error: unable to delete 'origin/myBranch-1236': remote ref does not exist
error: unable to delete 'origin/myBranch-1237': remote ref does not exist
... etc
然而,这些遥控器确实存在,我可以检查每一个。许多站点和人们建议我运行 git fetch --prune
来清理丢失的引用。这没有用,因为所有这些遥控器都存在。
我觉得我错过了一些小东西。每次我研究这个,似乎我正在做这个正确的,但我得到上述错误。