Git & GitHub Tips
Add Upstream Remote to Our Forked Git Repos
Assuming we have forked the repo.
Now we clone our forked repo:
$ git clone git@github.com:YOUR-USERNAME/THE-REPO.gitSee what remotes we have:
$ git remote -vv
origin git@github.com:YOUR-USERNAME/THE-REPO.git (fetch)
origin git@github.com:YOUR-USERNAME/THE-REPO.git (push)To add the upstream remote:
$ git remote add upstream git://github.com/UPSTREAM-USERNAME/THE-REPO.git
$ git remote -vv
origin git@github.com:YOUR-USERNAME/THE-REPO.git (fetch)
origin git@github.com:YOUR-USERNAME/THE-REPO.git (push)
upstream git@github.com:UPSTREAM-USERNAME/THE-REPO.git (fetch)
upstream git@github.com:UPSTREAM-USERNAME/THE-REPO.git (push)Syncing a fork
Fetch the branches and their respective commits from the upstream repository.
Commits to master will be stored in a local branch, upstream/master.
Check out your fork's local
masterbranch.
Merge the changes from
upstream/masterinto your localmasterbranch.
This brings your fork's master branch into sync with the upstream repository, without losing your local changes.
If you just want to sync up without local changes, you may push it after git merge:
Check What's Going to be Pushed?
For a list of files to be pushed, run:
How to Delete Local and/or Remote Branch?
To Contribute Multiple PRs?
Better use a dedicated branch for one PR, like below.
For PR-1:
Now there is another PR-2 you want to do, while waiting for the PR-1 to be accepted and merged:
How to "Rollback" the versions of one specific file?
git push --set-upstream origin master but somehow the old user is being used?
git push --set-upstream origin master but somehow the old user is being used?If you checked through git config --global -l or cat ~/.gitconfig but same issue remains, it's most likely caused by OSX Keychain. Resolve it by following below steps:
In Finder, search for the
Keychain Access appIn Keychain Access, search for
github.comGitHub Password Entry in KeychainFind the "internet password" entry for
github.comEdit or delete the entry accordingly.
Merge PR With Conflicts
Ref
Last updated
Was this helpful?