How to merge new changes with previous commit in git

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

What is the most efficient way to combine new changes with those from the previous commit, so that I only get one commit?

+4
source share
2 answers

git add -u && git commit --amend

This will do all the local changes and then use them to overwrite the previous commit. Note that if you already pushed the previous commit, this is a really bad idea.

+7
source

If you have not made the second set of changes, do what Kevin said. If you have one, use git rebase -i to crush them together.

+1
source

Source: https://habr.com/ru/post/1339102/


All Articles