如何修改以前提交的更多更改? [英] How to amend more changes to a previous commit?

查看:141
本文介绍了如何修改以前提交的更多更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在没有进行另一次提交的情况下将更多更改添加到回购库中的最新提交中?我需要使用提交之后所做的最新一组更改来更新最后一次提交。

解决方案

git commit --amend



这会将当前的分阶段更改添加到前一个提交中。



如果您已将前一个提交推送到共享存储库,例如GitHub ,但是你可能想要考虑一下这个问题。

如果其他人已经撤消了您的更改,修改提交可能会为他们创建合并困难。在这种情况下,最好创建一个新的提交来解决问题。



如果您尚未推送错误提交,或者您正在私人存储库,而不是向/从其他人推/拉变更,您不必担心这一点。


How can more changes be added to the latest commit in a repo without making another commit? I need to update the last commit with the newest set of changes that were made after that commit was made.

解决方案

git commit --amend

This will add your currently staged changes to the previous commit.

If you have pushed your previous commit to a shared repository, such as GitHub, you may want to think twice about doing this however.

If anyone else has pulled down your changes, amending the commit may create merge difficulties for them. In this case it is just better to create a new commit to fix the problem.

If you haven't yet pushed the bad commit, or if you are working in a private repository and not pushing/pulling changes to/from anyone else, you don't need to worry about this.

这篇关于如何修改以前提交的更多更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆