Last active
October 16, 2024 13:56
-
-
Save seLain/8bdf12c7196f3fccafdf067dec2696b2 to your computer and use it in GitHub Desktop.
Fix the thing GitHub keeps saying “This branch is X commits ahead, Y commits behind”
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 !! |
thank you!
Great, works for me!
Excellent, thanks!
Work fine, Thanks so much
You saved my life, thank you!
thanks!
After editing and merging PR's from Upstream from time-to-time, my Forked repository is now XX commits ahead.
I'm wondering, is there any way to squash all the extra commits that I've done so that it would say that my repository is just 1 commit ahead?
Thank you for sharing!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks! It helped :)