Update forked repo with remote repo

Auto merge

Add remote repository

# cd <forked-repo>
# git checkout 
# git remote add upstream <upstream-repo-git-link>
#git fetch upstream

Updating fork from remote repo

# git pull upstream <upstream-branch>

Example (This is what I did to sync from remote branch and push to forked repo)

# cd <forked-repo>
# git checkout
# git remote add upstream <upstream-repo-git-link>
# git fetch upstream
# git pull upstream master --rebase

As local repo changes are rebased, faced error while pushing changes to forked repo. Runt these commands to rebase changes for forked branch.

# git pull --rebase
# git push origin <forked-remote-branch>

 

Force Update

If normal merge doesn’t wok and you are ready to do force update of your forked repo branch with original repo branch:

#git remote add upstream <upstream-repo-git-link>
# git fetch upstream
# git checkout <upstream branch>
# git reset --hard upstream/<upstream-branch>  
# git push origin <forked-remote-branch> --force 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s