【问题标题】:What does happen if I stage a file, then modify it and do a commit and push?如果我暂存一个文件,然后修改它并执行提交和推送,会发生什么?
【发布时间】:2021-05-05 02:13:59
【问题描述】:

因此,例如,如果我有一个文件 index.html 并更改一些行并执行 git add index.html。然后我将再次修改 index.html 但不会进行阶段性更改。并执行git commitgit push。我最后的更改是否会应用到commit/push

【问题讨论】:

  • 你试过这个吗?请先告诉你的发现
  • 欢迎来到 Stackoverflow。添加到暂存区域的最后更改将在提交中。这也称为缓存。使用git diff --cached 查看将提交或提交的内容,使用git show HEAD 查看已提交的内容。通过Recording Changes to the Repository 了解,查看您的分阶段和未分阶段的更改部分可能对您来说特别有趣。

标签: git github commit git-stage


【解决方案1】:

不,您的最后更改不会被提交并推送到 git 服务器。只有暂存区 (git add) 中的文件会被提交 并且可以推送。如果你更改了一个文件并且没有添加到暂存区 (git add),那么你就不会提交或推送它到 git 服务器。

如果您还想添加最后的更改并将其推送到服务器,只需再次git add 然后commitpush 它。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-02-04
    • 2021-10-01
    • 2020-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多