Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to combine new changes with previous commit in git

Tags:

git

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 the ones from the previous commit so that I end up with just one commit?

like image 262
markdorison Avatar asked Feb 25 '23 03:02

markdorison


1 Answers

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.

like image 172
Lily Ballard Avatar answered Feb 28 '23 07:02

Lily Ballard