GitHub #
Warning: This post hasn't been updated for over a year. The information may be out of date.
Debugging #
Repository not found. #
Don’t have write access to remote repository. Ask a maintainer/admin to add you as contributor.
How to find whether I have write access? #
In browser, open a random file of the repository, and hit the edit button. If can edit, then have write access. (credit)
refusing to allow an OAuth App to create or update workflow #
Use token to login.
- Sign out from git
- Open
Keychain Access.app, delete the Internet password forgithub.com, or git config --global --unset credential.helper
- Open
- Push again, and when prompted to enter password, enter a personal access token.
Profile #
Fork related operations #
Pull Updates from Origin of Fork #
The GitHub PR method #
Step 0: Create draft PR.
Step 1: From your project repository, check out a new branch and test the changes.
git checkout -b their-main main
git pull https://github.com/their/repo.git mainStep 2: Merge the changes and update on GitHub.
git checkout main
git merge --no-ff their-main
git push origin mainExecuting the final command will immediately merge the changes and close the PR.
Done.
Keep own changes #
Scenario: I have a forked repository on GitHub, and want to pull the updates from the original repository, while keeping my own changes.
Step 1: Clone to local machine.
Step 2: Add original repository as remote (the name does not matter, can even call it spoon)
git remote add upstream https://github.com/something/something.git
git fetch upstreamStep 3: Open a new branch (optional)
If it takes a long time to resolve all the merge conflicts, this step will preserve the main branch for production until merge is ready.
git checkout -b merge-upstream main
git checkout -b merge-upstream masterStep 4: Run merge
If want to keep all fork commits:
git merge upstream/main main
git merge upstream/master master
# or with step 3
git merge upstream/main merge-upstream
git merge upstream/master merge-upstreamIf want clean commit history:
git rebase upstream/main
git rebase upstream/masterResolve any conflict, and commit.
Step 5: Merge new branch to main (optional)
Needed if have used Step 3.
git checkout main
git checkout master
git merge merge-upstream
git branch -d merge-upstreamDone.
Use everything upstream #
Scenario: I have used Vercel Deploy Button and now having a private non-fork repository. I did not change anything and only want to stick to the upstream.
First clone it to local machine.
Add original repository as remote, call it upstream: (the name does not matter, can even call it spoon)
Step 1: Clone to local machine.
Step 2: Add original repository as remote, call it upstream: (the name does not matter, can even call it spoon)
git remote add upstream https://github.com/something/something.git
git fetch upstreamStep 3: Run merge
# resolve all conflicts using upstream code:
# https://stackoverflow.com/a/10697551
git merge upstream/main main --allow-unrelated-histories --strategy-option theirsDone.
Contribute selected code to fork #
Step 1: Add upstream and pull
Step 2: Make branch based on upstream
git checkout -b fix-1 upstream/main
git checkout -b fix-1 upstream/masterStep 3: Change the files and commit
Step 4: Push to own remote fork
git push origin fix-1Step 5: Create PR with https://github.com/<original/repo>/pull/new/fix-1
Done.