git recipes

  • to fully sync commit logs from an upstream repo to your forked repo
# add upstream remote if not ready
git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPO.git

# verify remote, there are origin and remote
git remote -v

# fetch all updates from both remotes
git fetch --all

git checkout main    # switch to main branch

# reset to exactly match upstream
git reset --hard upstream/main

# force push to your fork
git push --force origin main

# clean up local branch references
git fetch --prune origin
git fetch --prune upstream