开发者

How to combine new changes with previous commit in git

开发者 https://www.devze.com 2023-02-10 02:56 出处:网络
I made a commit A and now have additional changes that if I committed would give me two commits A & B.

I made a commit A and now have additional changes that if I committed would give me two commits A & B.

What is the most efficient way to combine the new changes with t开发者_如何学运维he ones from the previous commit so that I end up with just one commit?


git add -u && git commit --amend

This will stage all local changes and then use them to rewrite the previous commit. Note that if you've already pushed the previous commit then this is a really bad idea.


If you haven't committed the second set of changes yet, do what Kevin said. If you have, use git rebase -i to squash them together.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号