2

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

3
  • 1
    You have to squash this 2 commits. You can follow this example -> internalpointers.com/post/squash-commits-into-one-git Commented Oct 3, 2019 at 11:28
  • You need to tell it how many commits to rebase on, git rebase -i HEAD~2 Commented Oct 3, 2019 at 11:33
  • i have two commit example A and B and i want au push B with code commit A Commented Oct 3, 2019 at 11:36

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.