Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save softquantum/97cd60757a5ac77643a7c8336dd442c1 to your computer and use it in GitHub Desktop.
Save softquantum/97cd60757a5ac77643a7c8336dd442c1 to your computer and use it in GitHub Desktop.
Fix the thing GitHub keeps saying “This branch is X commits ahead, Y commits behind”
ref stackoverflow:
https://stackoverflow.com/questions/41283955/github-keeps-saying-this-branch-is-x-commits-ahead-y-commits-behind
works by
1. git remote add upstream https://github/upstream/repo.git
2. git pull --rebase upstream master
2.1 git rebase --skip (if the conflicts are not true, skip the patches)
3. git push --force-with-lease origin master
If there are branches to fix
4. git checkout myfeature
5. git rebase master
6. git push --force-with-lease origin myfeature
=== If the above does not seem work ===
1. in your local master branch (or other branch that went wrong)
2. git rebase -i <commit-id> (the commit id should be the last id before the "base" id you want to rebase to)
3. squash or drop the redundant commits, leave only the first commit maybe (the first commit should be the base id you like to rebase to)
4. wq save and apply this rebase
5. git pull --rebase upstream master
6. git push --force-with-lease origin master
done !!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment