git:如何删除本地引用分支?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18506456/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
git: How to delete a local ref branch?
提问by Iowa
I have bit of a difficulty in deleting a local ref branch(refs/notes/origin/commits). I was able to delete the branch(refs/notes/origin/commits) in the remote repository using the command
我在删除本地引用分支(refs/notes/origin/commits)时有点困难。我能够使用命令删除远程存储库中的分支(refs/notes/origin/commits)
git push origin :refs/notes/origin/commits
but when i try to delete the same branch on my local repository, i get the below error
但是当我尝试删除本地存储库上的同一个分支时,出现以下错误
[User@centos Clone]# git branch -rd refs/notes/origin/commits
error: remote branch 'refs/notes/origin/commits' not found.
Any suggestions?
有什么建议?
回答by alexclooze
Just do
做就是了
git branch -d commits
to delete the local branch.
删除本地分支。
Use the -D
switch to delete it irrespective of its merged status.
-D
无论其合并状态如何,都可以使用开关将其删除。
Use
用
git update-ref -d refs/notes/origin/commits
to delete the ref.
删除参考。
You can also hard-delete it as mentioned in other answers with
您也可以像其他答案中提到的那样硬删除它
rm -rf .git/refs/notes
回答by silvio
You have notes in your git repository, you can delete one note with
您的 git 存储库中有笔记,您可以删除一条笔记
git notes remove <commit>
For deleting of all notes you have to remove the 'notes' directory
要删除所有笔记,您必须删除“笔记”目录
rm -rf .git/refs/notes
or you can use the git update-ref command.
或者您可以使用 git update-ref 命令。
git update-ref -d refs/notes/commits
回答by Ajeesh
you can just delete the file out of the .git directory. From the repository root, a command like this will get it:
您可以从 .git 目录中删除该文件。从存储库根目录,这样的命令将得到它:
rm .git/refs/tags/refs/original/refs/heads/master
The path may be slightly different if the git-tag command failed, so you may want to cd .git/refs and find the offending head by trial-and-error. Deleting the file will remove the reference from your local repository.
如果 git-tag 命令失败,路径可能略有不同,因此您可能需要 cd .git/refs 并通过反复试验找到有问题的头。删除文件将从本地存储库中删除引用。