如何将文件添加到最后一次提交git?

这个问题在这里已经有了答案:

  • 如何修改现有的,未完成的提交? 27个答案

  • 是的,有一个命令git commit --amend用于“修复”上次提交。

    在你的情况下,它会被称为:

    git add the_left_out_file
    git commit --amend --no-edit
    

    --no-edit标志允许修改提交而无需更改提交消息。

    编辑:警告你永远不应该修改公共提交,你已经推到公共仓库,因为修改确实是从历史记录中删除上次提交并创建新的提交与来自该提交的组合更改和修改时添加的新提交。


    如果您没有在远程推送更新,那么简单的解决方案是使用以下命令删除最后一个本地提交: git reset HEAD^ 。 然后添加所有文件并再次提交。

    链接地址: http://www.djcxy.com/p/1393.html

    上一篇: How to add a file to the last commit in git?

    下一篇: Changing git commit message after push (given that no one pulled from remote)