1

I have made the following commits in my branch and pushed them to remote

commit 5
commit 4
commit 3
commit 2
commit 1

I now want to squash commits 1, 2 & 3 and remove commits 4 & 5 (dont need the changes anymore) How can i do this?

user964287
  • 713
  • 1
  • 7
  • 11
  • 1
    Interactive rebase. You'll need to force push, which may not be what you want if you're sharing your branch with other people, because it will cause synchronization issues if they have copies of your old commits. –  Apr 08 '14 at 04:17
  • yes, i am sharing this with others. is there any other option? – user964287 Apr 08 '14 at 04:25
  • If you're not going to force push, then you can't really squash commits, though you can still revert any changes that you don't want. How many other people are you sharing your branch with? –  Apr 08 '14 at 04:45
  • You should probably just accept that commits 1, 2, and 3 are not squashed, and use `git revert` for 4 and 5. – Chris Hayes Apr 08 '14 at 06:02

1 Answers1

1

Once pushed, you cannot easily change the history without affected other users, so it becomes a communication problem.

One approach would be:

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250