... | @@ -19,28 +19,28 @@ |
... | @@ -19,28 +19,28 @@ |
|
|
|
|
|
# Pulling from git when your local version has been modified
|
|
# Pulling from git when your local version has been modified
|
|
Here's a typical scenario:
|
|
Here's a typical scenario:
|
|
``` bash
|
|
``` console
|
|
user@host:~/repo/blocks$ git checkout <branch>
|
|
user@host:~/repo/blocks$ git checkout <branch>
|
|
(git tells you it will not check out <branch> because you have changes that have not been committed)
|
|
(git tells you it will not check out <branch> because you have changes that have not been committed)
|
|
```
|
|
```
|
|
|
|
|
|
You now have three choices:
|
|
You now have three choices:
|
|
1. Commit the changes to the current branch, because you know you want them:
|
|
1. Commit the changes to the current branch, because you know you want them:
|
|
``` bash
|
|
``` console
|
|
user@host:~/repo/blocks$ git commit -am "<commit message>"
|
|
user@host:~/repo/blocks$ git commit -am "<commit message>"
|
|
user@host:~/repo/blocks$ git push
|
|
user@host:~/repo/blocks$ git push
|
|
```
|
|
```
|
|
2. Delete the changes by reverting to the previous commit, because you know you don't want them:
|
|
2. Delete the changes by reverting to the previous commit, because you know you don't want them:
|
|
``` bash
|
|
``` console
|
|
user@host:~/repo/blocks$ git reset --hard HEAD
|
|
user@host:~/repo/blocks$ git reset --hard HEAD
|
|
```
|
|
```
|
|
3. Store the changes locally, because you're not sure if you want them yet:
|
|
3. Store the changes locally, because you're not sure if you want them yet:
|
|
``` bash
|
|
``` console
|
|
user@host:~/repo/blocks$ git stash
|
|
user@host:~/repo/blocks$ git stash
|
|
```
|
|
```
|
|
|
|
|
|
After doing any of these three things you should be able to check out the branch you want without any issues.
|
|
After doing any of these three things you should be able to check out the branch you want without any issues.
|
|
``` bash
|
|
``` console
|
|
user@host:~/repo/blocks$ git checkout <branch>
|
|
user@host:~/repo/blocks$ git checkout <branch>
|
|
```
|
|
```
|
|
|
|
|
... | | ... | |