git - 如何从标签中删除 Git 提交?

标签 git github

这就是所做的:

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/

相关文章:

github - 按安装大小对已安装的 BREW 软件包进行排序

windows - 将 Git Windows 版本与 Git 源代码管理提供程序一起使用的入门问题

git - TortoiseGit - 找不到 git

git - 如何重命名 GitHub 存储库中的文件夹而不显示该文件夹已被删除?

open-source - 托管在 github 上的开源代码可以是闭源代码吗?

github - 如何使用 GitHub API 一次检索多个用户?

Git diff 没有列出对文件的特定更改?

git - 如何执行相当于 "git add -p -w"的操作?

git - 我怎样才能对公共(public) stash 一些文件,同时在 Github 存储库中对它们进行版本控制

git - 对于 Git 和 Github,术语 fork、master、origin、push、pull 意味着什么?