Skip to content

Instantly share code, notes, and snippets.

@Shakil-Shahadat
Last active April 22, 2021 20:49
Show Gist options
  • Save Shakil-Shahadat/7365b01a81e1c4e60bf0309a7f14748f to your computer and use it in GitHub Desktop.
Save Shakil-Shahadat/7365b01a81e1c4e60bf0309a7f14748f to your computer and use it in GitHub Desktop.
Steps to sync a forked repository
// Check if original remote repository is already added or not
git remote -v
// Output
origin https://github.com/YOUR_NAME/REPO_NAME.git (fetch)
origin https://github.com/YOUR_NAME/REPO_NAME.git (pull)
upstream https://github.com/ORGINAL_USER/REPO_NAME.git (fetch)
upstream https://github.com/ORGINAL_USER/REPO_NAME.git (push)
// If it only shows origin, original remote repo is not added
// If not, add it
git remote add upstream https://github.com/ORGINAL_USER/REPO_NAME.git
// Get latest changes from original remote repo
git fetch upstream
// Merge those changes to local branch
git merge upstream/main
// Change main to original users branch name
// Push changes to your remote repo
git push
// If any more help is needed, check https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/syncing-a-fork
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment