0

For example i have 10 commit in my current branch, now i want to to turn last 4 commit into one commit... I have pushed all the commit to my remote branch.. now can i make my last 4 commit message into new commit message?

I want to do it, coz, my last 4 commit message was meaningless...

I tried like this:

git rebase -i HEAD~2

it fires me message like, i have successfully rebased but later, i try to push this, it says, nothing to commit..

Can anyone help me?

2 Answers2

3

if your branch can be rewritten on the remote, you could do it like this:

git checkout my-branch
git reset --soft my-branch~4 # set branch pointer 4 revisions behind... put all differences between the 4 revisions on index
git commit -m "The messsage I want"
# if you like the result
git push the-remote my-branch

And that should be it.

eftshift0
  • 26,375
  • 3
  • 36
  • 60
  • Thanks but i cant push.. Your every command working in locally but i cant push it now, why? it message me that Everything is updated –  Jul 05 '19 at 18:39
1

You can just revert the last four commits using --soft flag and then make a new commit. Take a look to this question

Yasiel Cabrera
  • 540
  • 4
  • 11