fico7489
fico7489

Reputation: 8560

Which is best way to merge more commits into one commit

I have new feature branch named "new_feature". I create 2 commits named:

"testing"

and

"testing2"

I push this commits to git, project leader checkout my branch and he is satisfied. After this I fix just one more small fix with commit "small_fix", so now I have three commits:

"testing"
"testing2"
"small fix"

But I want merge all this in one commit named "new_feature_all_done". I deleted remote branch named "new_feature", now I need to merge this 3 commits in one commit(new_feature_all_done) and push branch "new_feature" to remote but this time with one commit(new_feature_all_done). Which is best way to do this ?

I can copy my working folder somewere on disc, delete local branch "new_feature", create branch "new_feature" again and then paste working directory from disc to git working folder and then commit and push changes, but this in dirty way and I want more elegant way...

Upvotes: 0

Views: 36

Answers (1)

u_mulder
u_mulder

Reputation: 54831

Try interactive git rebase:

git rebase -i BRANCH_NAME~3

Here

  • BRANCH_NAME - name of your local branch
  • 3 - number of commits in your branch to be rebased.

Upvotes: 1

Related Questions