这就是所做的:
git add test.txt
git commit
git tag foo
git push origin foo
请注意,文件test.txt
未提交到任何分支。它只属于标签foo
。现在我想将其从远程存储库历史记录中删除:
git checkout 4b4ae4b
git log # I can see the commit in the log history
git reset HEAD~1
我明白了:
$ git status
HEAD detached from 4b4ae4b
Untracked files:
(use "git add <file>..." to include in what will be committed)
test.txt
nothing added to commit but untracked files present (use "git add" to track)
下一步是什么?如何从历史记录中完全删除它,然后确保远程存储库(在 GitHub 中)也丢失提交?
最佳答案
如果提交仅包含在标签中,则必须删除该标签:
git push origin :foo
关于git - 如何从标签中删除 Git 提交?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61380985/