git - 如何只向 GIT 提交一条消息?

标签 git

假设我一直在一个分支上工作并且已经提交了我的工作但是想 在分支待办事项列表的下一步日志中添加一条消息。次 我可能想这样做包括:

  • 切换分支从事其他工作 - 需要提醒自己下一步该做什么
  • 周末
  • 其他

是否可以在不提交任何文件的情况下提交到 git?换句话说:是否可以只向 GIT 提交一条消息?

最佳答案

是的。有可能的。我永远记不起怎么做,总是需要谷歌(所以我写了一个问答,希望这能帮助我记住)。

命令是:

git commit --allow-empty --only

--allow-empty 的文档如下:

Usually recording a commit that has the exact same tree as its sole parent commit is a mistake, and the command prevents you from making such a commit. This option bypasses the safety, and is primarily for use by foreign SCM interface scripts.

文档很有意义,但不容易搜索。

关于git - 如何只向 GIT 提交一条消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18879104/

相关文章:

git - 如何在 IIS 上设置 Git 裸 HTTP 可用存储库

git - 如果你使用 git rebase 和 push,对比如果你使用 git pull、merge 和 push,它对项目维护者 merge 的工作有帮助吗?

当前和头部之间的 Git 差异

bash - 将 `git diff --name-only` 的输出用于非 ASCII 字符的文件名

git repo 已损坏,无法状态为 : "BUG: fsmonitor.c:21: fsmonitor_dirty has more entries than the index"

git - git分支有什么用?

git stash apply @stash{x} 不适合我

git - 无法使用 git 克隆任何存储库

git - 如何在 git push 上修复 "cannot be resolved to branch"?

svn - 如何在 SVN 存储库中的源之间比较 Git 存储库中的源