我使用我的两台笔记本电脑和我的个人GitHub帐户模拟两个使用git在团队中工作的开发人员。我的回购只有一个master
和一个feature
分支,以及一个简单的文本文件。
在一台笔记本电脑(一个开发人员的帐户)上,我使用命令行bash发出git命令。我将功能与master合并,然后在本地删除:$ git branch -d feature
当然,单独推送不会删除远程功能分支,所以我这样做:$ git push origin --delete feature
然后,我希望看到这个远程删除显示在另一台笔记本电脑上(其他开发人员使用SourceTree做git的东西)但SourceTree上的原始功能仍然存在,尽管有几个令人耳目一新......
我环顾四周,想着也许还有其他的命令。我遇到了以下两个:
$ git push origin :feature
$ git push -u origin feature
但是,我为上面的每个git bash命令(第一个开发人员)得到以下两个错误:
error: unable to delete 'feature': remote ref does not exist
error: failed to push some refs to 'https://github.com/MyRepo/Repo.git'
error: src refspec feature does not match any.
error: failed to push some refs to 'https://github.com/MyRepo/Repo.git'
这两条错误消息表明远程功能分支确实已被删除。对?
我错过了什么?为什么第一个人完成的远程分支删除不会对遥控器生效?
在本地清除远程删除的分支(以及其他):
$ git remote prune origin
请参阅远程分支列表:
$ git branch -r