Working With Forks

Working With Forks

A reference document for myself so I don’t have to Google the same things every time.

Syncing Your Fork

# Add a new remote upstream repository
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git

# Sync your fork
git fetch upstream
git checkout main
git merge upstream/main

# Sync your fork's remote repository
git push

Sources:

Working With Somebody Else’s Branch In Their Fork of the Same Repository

Assuming you already have cloned your own fork of the repository:

git remote add other https://github.com/OTHER_FORK_OWNER/OTHER_FORK_REPOSITORY.git

git fetch other

# Checkout new branch to work on
git checkout -b add-other-changes

# Pull their branch 
git pull other other-fork-branch

Once you’ve made changes and want to push to your remote:

git push origin HEAD

If you want to list the remotes you have added for the repository, run:

git remote -v

Sources:

Written on April 20, 2023