I am trying to make two commit in one and push it to a new branch, I tried to use git rebase -i but nothing worked
1 Answer
As an alternative, you can also
git checkout -b new_branch git reset --soft HEAD~2 # rewinds HEAD back 2 commits while keeping changes git commit -m "Message for both commits" git push origin HEAD if you're not fond of interactive rebasing or don't feel confident enough with it.
Before :
X---A---B <<< your_branch After :
X---A---B <<< your_branch \ C <<< new_branch where C contains cumulative changes of A and B, like after a squash.
squashthis 2 commits. You can follow this example -> internalpointers.com/post/squash-commits-into-one-gitgit rebase -i HEAD~2