Wednesday, September 28, 2016

Git - remotes

git clone <remote_location> <clone_name> - Create a duplicate (clone) of remote_location and locally call it clone_name

git remote -v - Display a list of Git project remotes

git fetch - Bring changes in remote master down to origin/master branch (not my local master branch)

git merge origin/master - Bring changes in origin/master branch into my local master branch


Workflow:
- Fetch and merge changes from remote
git fetch
git merge origin/master
- Create branch to work on new stuff
git branch <my_new_branch>
- Work on stuff in my branch and then commit work
git checkout <my_new_branch>
vi mychange.txt
git add mychange.txt
git commit -m "My message"
- Fetch and merge from remote again
git fetch
git merge origin/master
- Push my branch up to the remote for review
git push origin <my_new_branch>

[Edit]

The excellent Mark Moser suggests the following shortcut:

git pull

Instead of:

git fetch
git merge origin/master

[/Edit]