solarflare
solarflare

Reputation: 441

Squash group of commits but leave others

I want to squash commits only made by me and only on my feature branch.

I'm finding plenty of examples for situations where there is only one dev on a project who can squash whatever he likes to his own branch at will.

Nothing for when there are multiple devs with simultaneous commits.

When I try something like this:

git rebase -i HEAD~5

The next step is where I have problems:

pick asd324 Someone elses commit 1
pick aswe24 Someone elses commit 2
pick assd24 Someone elses commit 3
pick asd324 My commit I want to squash 1
pick ssdc24 My commit I want to squash 2
pick a23224 My commit I want to squash 3
pick 444v24 Someone elses commit 4
pick asbnjl Someone elses commit 5
pick 3hn324 Someone elses commit 6
pick 2gew24 Someone elses commit 7

# Rebase asdsdad..asdasdas onto asdasdasd (10 commands)

There's options to pick, squash etc but not sure what options need to be used for the commits that I have no authority to touch or change. They are other peoples code, and on a different branch although we are all merging into the same branch.

How do I go about this?

Thanks

Upvotes: 1

Views: 126

Answers (1)

eftshift0
eftshift0

Reputation: 30212

If the branch is already published, as as it seems to be the case cause you have revisions from other developers after yours, then you are out of luck, unless you are (all) ok with rewriting history of that branch.... or you will get an earful. When you squash your revisions and then apply the other (later) revisions from the other developers, you are creating new revisions.

Upvotes: 3

Related Questions