- Remote - Somewhere code is stored, not on your machine. In this case a GitHub Repo.
- Origin - When we clone a repo the source of that clone is added as this remote location.
- Upstream - What we are naming the remote location of the original repo we forked.
- Fetch - Git command to retrieve new work from an upstream.
- Merge - Used to combine the fetched changes with your local work.
- Pull - Fetch & Merge in one go.
- Push - Upload your local changes to a remote repo.
- Have a repo cloned to your computer - Lesson 1
-
Navigate to your repo if you're not already there
Set-Location C:\GitHub\GitDemo -
View current remote
git remote -vYou should see the origin, which was added when you cloned the repo.
origin https://github.com/<<USERNAME>>/GitDemo.git (fetch) origin https://github.com/<<USERNAME>>/GitDemo.git (push) -
Add remote named 'upstream' to refer to the original repo that we forked & cloned (someone elses code).
git remote add upstream https://github.com/jpomfret/GitDemo.git -
View remotes again
git remote -vYou should now see the origin and upstream.
origin https://github.com/<<USERNAME>>/GitDemo.git (fetch) origin https://github.com/<<USERNAME>>/GitDemo.git (push) upstream https://github.com/jpomfret/GitDemo.git (fetch) upstream https://github.com/jpomfret/GitDemo.git (push)
Folks have been working on the jpomfret code base and it's now got newer code than your fork.
-
Pull changes from upstream into your clone (master branch in this example)
git pull upstream master -
Push changes to your fork
git push -
Check GitHub - your fork should now show you're back in sync.
This Branch is even with jpomfret:master.
-
Bye, Bye, Bye. - We're now NSync :D.