seemvision
seemvision

Reputation: 242

Remote branch is both behind and ahead of master

I used BFG Repo Cleaner as instructed here, and pushed to remote.

After that I realized that my branches are both ahead and behind by some hundred commits.
Each branch should be ahead by few most recent commits prior to using the repo cleaner. I think it created a brand new completely disjoint history.

I tried to perform a rebase master onto each branch, but there appears to be a lot of conflict files. It's pretty much going through the history and expecting to resolve conflicts for each commit. Obviously this is very time consuming, and there's a lot of room for error.

Is there a cleaner and faster way to fix all these local branches to be ahead of master by recent commits only?

Upvotes: 2

Views: 468

Answers (1)

VonC
VonC

Reputation: 1328712

I think it created a brand new completely disjoint history.

Yes, that is what BFG does: it rewrites the history in order to purge the commits from certain (big) files.

If you have forced push to the remote, you need to fetch and reset your local branch to the new remote one (make sure you don't have local modifications in progress).

git fetch
git branch tmp
git reset --hard origin/myBranch

If you have in tmp a few new commits, git cherry-pick them on top of your reset branch

Then you can resume making new commits from that new state.

Upvotes: 3

Related Questions