Skip to content

Instantly share code, notes, and snippets.

View seLain's full-sized avatar
😭
life is tough

Victor Hu seLain

😭
life is tough
View GitHub Profile
@seLain
seLain / gist:8bdf12c7196f3fccafdf067dec2696b2
Last active October 24, 2025 14:23
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
@seLain
seLain / gist:92938d7eb4e122502f005b34d51abe1b
Created August 7, 2018 14:39
Create PR with specific commit
git fetch --all # or whatever to make sure your repo consistent with origin
git checkout -b new_branch_for_single_change upstream/master # or origin mater, dependes where's your base source
git cherry-pick hashcode_of_specific_commit
git push -u origin new_branch_for_single_change # push this new branch to origin
then create PR from new_branch_for_single_change branch on origin to upsteam
@seLain
seLain / gist:688fab5bef49a94cce4a8e40bfb4fe4c
Created August 19, 2018 00:35
Checkout specific PR and push as new branch
https://help.github.com/articles/checking-out-pull-requests-locally/
checkout from origin
git fetch origin pull/ID/head:BRANCHNAME
git checkout BRANCHNAME
<do modifications>
<add>
<commit>
git push origin BRANCHNAME
@seLain
seLain / gist:4ec25de9fafebebf449e12547a21fb0b
Created August 19, 2018 00:42
Change author of specific commit
https://stackoverflow.com/questions/3042437/how-to-change-the-commit-author-for-one-specific-commit
git rebase -i <earliercommit>
for each commit you want to change:
change the text from "pick" to "edit"
git commit --amend --author="Author Name <[email protected]>"
git rebase --continue
git rebase --continue
done