【问题标题】:How can I commit only staged hunks in git? [duplicate]我怎样才能在 git 中只提交分阶段的帅哥? [复制]
【发布时间】:2021-09-15 13:29:01
【问题描述】:

我运行这些命令来提交:

git add --all -p
// Then use "y" to stage hunks, and use "n" to not stage hunks
// I want to commit hunks which staged with "y"

git commit -a
// Then commit all

但是当我检查时,所有在 git add 中使用“y”和“n”的帅哥都提交到分支 我怎么能只提交我在使用 git add 时选择的帅哥?

【问题讨论】:

  • 不要使用-a 运行 git commit?您是在告诉 git 暂存所有修改和删除的内容并提交。另外,你表演的是大块头,而不是大块头。

标签: git github


【解决方案1】:

只需使用git commit 而不是git commit -a-a 选项将暂存所有新的和修改过的文件,基本上使您以前的暂存活动过时。

看这里:https://git-scm.com/docs/git-commit 在这里:https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging

【讨论】:

    猜你喜欢
    • 2016-06-18
    • 2020-11-27
    • 1970-01-01
    • 2021-07-30
    • 2017-05-13
    • 2010-11-17
    • 2019-10-21
    • 2018-08-27
    • 1970-01-01
    相关资源
    最近更新 更多