0

This may be a little vaque, but I am completely stunned by this problem. I am working, with a friend, on one branch. Sometimes, when we accumulate a lot of "pointless" commits like "fixed typo" or whatever, he squashes them and then pushes them with --force flag.

Next, I pull those changes and try to commit my things. When I try to push, I am getting a lot of old commits to push also. I understand that they are there because the dissapeared from the repo. But this is a problem, since after this, he needs to solve a lot of conflicts.

What can we do with this?

Tomek Buszewski
  • 7,659
  • 14
  • 67
  • 112
  • You should squash before pushing. If the changesets aren't intended to be shared, don't share them. If you can't do that you must ensure everyone gets rid of the superfluous changesets once they're squashed, or you risk someone inadvertantly pushing them back to central/shared repositories. – Lasse V. Karlsen Dec 21 '15 at 12:44
  • Basically, he squashes before merging with `master`. But then, there are some changes/fixes are we are back to our branch. So what should I do, also squash before pushing? – Tomek Buszewski Dec 21 '15 at 12:48
  • Possible duplicate of [How do I recover/resynchronise after someone pushes a rebase or a reset to a published branch?](http://stackoverflow.com/questions/4084868/how-do-i-recover-resynchronise-after-someone-pushes-a-rebase-or-a-reset-to-a-pub) – Andrew C Dec 21 '15 at 19:40

1 Answers1

2

You need to rebase against that branch since the history has changed and your version of that branch is no longer reachable with your remote's version of that branch.

Do this (assuming the shared branch is called featureA):

git fetch
git rebase origin/featureA

Then you should be able to push without those old commits getting in the way (won't even have to force push as well)

Jonathan.Brink
  • 23,757
  • 20
  • 73
  • 115