hectane logo

How to update a forked repo from original one

Sync new changes from original reposiotry to your repository

How to update a forked repo from original one

You can update your forked repository with changes from the original repo with the below steps.

Step 1: Go to your local repository folder

cd project_folder

Step 2: Change your branch to master or the branch where you want to pull the changes from original repository

git checkout master

Step 3: Verify your current origins are configured for fetch and push with below command

git remote -v

Step 4: Add a upstream origin to your local repository with the below command

git remote add upstream https://github.com/-username-/-original-repository.git

Step 5: Verify the upstream is added to your local git

git remote -v

It should show now 4 lines with 2 origins and 2 upstream where origin is your repository and upstream is the original repository where you forked from.

Step 6: Fetch all changes from the original repository

git fetch upstream

Step 7: You can either merge your changes to your master or you can do a rebase.

git merge upstream/master

Or

git rebase upstream/master

Step 8: Push the new changes to your repository.

// Below lines are if required to do a force push

If has some warnings you can check and then if all are good you can do a force push

git push origin master --force