Skip to content

Latest commit

 

History

History
35 lines (27 loc) · 1.08 KB

Remote-Repos.md

File metadata and controls

35 lines (27 loc) · 1.08 KB

All about remote repositories

Create a clone

git clone <url>

Setting a remote

git remote add origin <url>

Keeping forked repo in sync

1. Setting upstream

git remote add upstream <url of forked repo>

2. Fetching latest changes from upstream

git fetch upstream

3. Rebasing

With the rebase command, you can take all the changes that were committed on one branch and replay them on another one

  • git checkout b
  • git rebase upstream/master -Applies changes of master branch of remote upstream on the branch b.

4. Push to cloned repo

git push origin master

5. Reset to upstream (CAUTION!)

You might want to keep a copy of local work first:

git commit -a -m "Saving my work, just in case"
git branch my-saved-work

And then: git reset --hard upstream/master

Reviewing pull requests

git fetch upstream pull/PR_Number/head:branchName
git checkout branchName

If you mess up, you can replace the changes in your working tree with the last content in head

git checkout --