catrapture
catrapture

Reputation: 1976

Squash Commits on Pull request

Ive been asked to squash the commits on my pull request on github. When i run

git rebase -i HEAD~5

It looks like this

pick bcbb30d My commit comment
pick 8564706 Other persons commit comment
pick c99bdd2 Other persons commit comment
pick 07bb5b9 Other persons commit comment
pick 2bcff6f Other persons commit comment
pick 77a5076 My commit comment

As I only want to squash MY commits, is it ok to put 'squash' against all of mine but one (leaving it as 'pick') and have the other people's commits left as 'pick' too? Will this only squash my commits?

Upvotes: 1

Views: 1022

Answers (2)

Ben
Ben

Reputation: 693

Try something like this

pick 8564706 Other persons commit comment
pick c99bdd2 Other persons commit comment
pick 07bb5b9 Other persons commit comment
pick 2bcff6f Other persons commit comment
pick bcbb30d My commit comment
squash 77a5076 My commit comment

You are free to reorder commits as well as squash them. Therefore, you should probably put your commits on top of the others, assuming there are not inter-commit dependencies.

Upvotes: 3

Mureinik
Mureinik

Reputation: 311393

Assuming the patches would apply cleanly, you can reorder them in the editor you get from the git rebase -i command, and then squash only yours:

pick 8564706 Other persons commit comment
pick c99bdd2 Other persons commit comment
pick 07bb5b9 Other persons commit comment
pick 2bcff6f Other persons commit comment
pick bcbb30d My commit comment
squash 77a5076 My commit comment

You will now get an editor to fix you (combined) commit message.

Upvotes: 2

Related Questions