0 votes
1 view
in DevOps and Agile by (20k points)

For example, I have 10 commits in my current branch, now I want to to turn last 4 commits 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 to like this:

git rebase -i HEAD~2

it fires me a message as I have successfully rebased but later, I try to push this, it says, nothing to commit...

Can anyone help me?

1 Answer

0 votes
by (12.4k points)

You can use the command: 

git rebase -i

If you want to merge 2 commits to a recent one then you can run the command

 git rebase -i HEAD~2 

now spawn an editor listing all commits the rebase will traverse. Now to proceed with squashing change the first word of the second line from "pick" to "squash" and save your file. This will squash your 2 commits in one. 

For more information on Git, you can join git training.

To know more about git commands, check out:

Welcome to Intellipaat Community. Get your technical queries answered by top developers !

Categories

...