Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

How do I reset the git master branch to the upstream branch in a forked repository?

You can reset your local master branch to the upstream version and push it to your origin repository.

Assuming that "upstream" is the original repository and "origin" is your fork:

# ensures current branch is master
git checkout master

# pulls all new commits made to upstream/master
git pull upstream master

# this will delete all your local changes to master
git reset --hard upstream/master

# take care, this will delete all your changes on your forked master
git push origin master --force
(You can define the original repo as "upstream" with git remote add upstream /url/to/original/repo.)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #How #I #reset #git #master #branch #upstream #branch #forked
ADD COMMENT
Topic
Name
6+8 =