[HOW TO] Please, commit your changes or stash them before you can switch branches.

In the morning, I pull git to deploy, and unlucky, this paragraph shows me:
Please, commit your changes or stash them before you can switch branches.

Ya I see, a long time ago, I changed one line on file. So it don't like the git repositories file. Next, I have to change/ recovery file on my local as git repositories file.


I see it commons sense. So somebody know the method to fix. Next, google.


In this article I show some cases:


1. You are right, and this change is not affect to teams. You can commit this change using

git commit -m "My message"

2. Stash it


Stashing acts as a stack, where you can push changes, and you pop them in reverse order.
git stash

Do the merge, and then pull the stash:
git stash pop

3. Discard local changes for a specific file
git reset --hard. 
or 
git checkout -t -f remote/branch

4. Discard local changes for a specific file
git checkout filename



Tiến Phan - R0039

Knowledge is Endless

Sharing for Success



0 nhận xét:

Post a Comment