Skip to content

Instantly share code, notes, and snippets.

@begin29
Created December 2, 2015 19:32
Show Gist options
  • Save begin29/b791cb2f6bc126bdf21d to your computer and use it in GitHub Desktop.
Save begin29/b791cb2f6bc126bdf21d to your computer and use it in GitHub Desktop.
How to get new changes from origin repository
# Make sure you have 2 origins (your forked project and project from which you forked)
$ git remote -v
# origin git@github.com:a-LERT/schoolTest.git (fetch)
# origin git@github.com:a-LERT/schoolTest.git (push)
# upstream git@github.com:begin29/schoolTest.git (fetch)
# upstream git@github.com:begin29/schoolTest.git (push)
# If you have only one add it
$ git remote add upstream git@github.com:begin29/schoolTest.git
# fetch fresh changes
$ git fetch upstream master
# merge it to forked repository
$ git checkout master
$ git merge upstream/master
# checkout to own feature branch and rebase(merge) new changes to it
$ git checkout my-feature
$ git rebase master
$git log
#now you will see your changes with fresh changes from repository which you forked
# if you will get conflicts after rebase
# fix conflicts and add it to git status
$ git add file1 file2 # or `git add .`
$ git rebase --continue
# it will merge your and other commits with resolved conflicts
# if something went wrong you within rebase process
# you can abort rebase
$ git rebase --abort
# you will have sate before rebase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment