|
|
Synchronize updates in this repository by pulling them from the remote:
|
|
|
``` bash
|
|
|
user@host:~/repo/blocks$ git pull
|
|
|
```
|
|
|
|
|
|
# Pulling from git when your local version has been modified
|
|
|
Here's a typical scenario:
|
|
|
``` console
|
|
|
$ git checkout <branch>
|
|
|
(git tells you it won't check out <branch> because you have changes you haven't committed)
|
|
|
```
|
|
|
|
|
|
You now have three choices:
|
|
|
1. Commit the changes to the current branch, because you know you want them
|
|
|
2. Delete the changes by reverting to the previous commit, because you know you don't want them
|
|
|
3. Store the changes locally, because you're not sure if you want them yet
|
|
|
|
|
|
In case 1, you do:
|
|
|
``` console
|
|
|
$ git commit -am "<commit message>"
|
|
|
$ git push
|
|
|
```
|
|
|
|
|
|
In case 2, you do:
|
|
|
``` console
|
|
|
$ git reset --hard HEAD
|
|
|
```
|
|
|
|
|
|
In case 3, you do:
|
|
|
``` console
|
|
|
$ git stash
|
|
|
```
|
|
|
|
|
|
After doing any of these three things you should be able to check out the branch you want without any issues.
|
|
|
``` console
|
|
|
$ git checkout <branch>
|
|
|
```
|
|
|
|
|
|
**BONUS:** Let's assume you were in case 3 and you stashed the changes, then checked out a working branch. Now you want to switch back to master and get back the changes you made. Here's what you do:
|
|
|
``` console
|
|
|
$ git checkout master
|
|
|
$ git stash pop
|
|
|
```
|
|
|
|
|
|
For more information, see Git's official documentation for the stash command:
|
|
|
https://git-scm.com/book/en/v1/Git-Tools-Stashing |
|
|
\ No newline at end of file |