famas23
famas23

Reputation: 2280

git rebase and squash the commit with a message

Is it possible when we resolve some git conflict via git rebase to squash that rebase via simple message for example "resolve conflicts".
This is my commit history after resolving a specific conflict: enter image description here

As you see the last 3 commits represent a git rebase then git push -f. I think it's more logical to set just one commit with a message instead of having 3 (the number of commits on the current branch) commits

Upvotes: 0

Views: 65

Answers (1)

Englund
Englund

Reputation: 1117

I would recommend doing an interactive rebase, picking the commits you want and the ones you want to squash you prefix with squash instead of pick.

For example in your case it would look something like this (the number is how many commits after HEAD you would like to rebase):

git rebase -i HEAD~3

You will then get a prompt with the commits and their message which will look something like this:

pick <HASHID> Initial Commit 
pick <HASHID> Login via mail instead of username
pick <HASHID> Add missing files

Just change the pick to squash (And keep one as the pick commit).

You will then be able to rewrite that commit message and voila you have 1 commit which you do git push -f if you would like.

Upvotes: 1

Related Questions