Skip to main content
GitHub

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.

  1. Sign out from git
    • Open Keychain Access.app, delete the Internet password for github.com, or
    • git config --global --unset credential.helper
  2. Push again, and when prompted to enter password, enter a personal access token.

Profile #

Pull Updates from Origin of Fork #

Ref: git - Pull new updates from original GitHub repository into forked GitHub repository - Stack Overflow

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 main

Step 2: Merge the changes and update on GitHub.

git checkout main
git merge --no-ff their-main
git push origin main

Executing 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 upstream

Step 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 master

Step 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-upstream

If want clean commit history:

git rebase upstream/main
git rebase upstream/master

Resolve 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-upstream

Done.

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 upstream

Step 3: Run merge

# resolve all conflicts using upstream code:
# https://stackoverflow.com/a/10697551
git merge upstream/main main --allow-unrelated-histories --strategy-option theirs

Done.

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/master

Step 3: Change the files and commit

Step 4: Push to own remote fork

git push origin fix-1

Step 5: Create PR with https://github.com/<original/repo>/pull/new/fix-1

Done.