Information Technology Reference
In-Depth Information
The command
$ git checkout master
produces the warning:
error:
Your local changes to the following files
would be overwritten by checkout:
i1.txt
The settings are as follows: you are in
info
branch, the file
i1.txt
is modified,
and you want it to be committed in the
master
branch.
First, save the current state of the working directory with:
$ git stash
The repository becomes clean, the working directory reflects the latest revision in
the
info
branch, and your modifications to
i1.txt
file were stored in a temporary
area called stash. Because the repository is clean you can safely checkout of the
mas-
ter
branch:
$ git checkout master
The above command doesn't affect in any way your stashed work.
To retrieve your stashed modifications execute the following command:
$ git stash pop
The state of the working directory will be adjusted to reflect the changes stored with
stash command. The above command will produce a warning about conflicting
changes:
CONFLICT (modify/delete):
i1.txt deleted in Updated upstream and modified in
Stashed changes.
Version Stashed changes of i1.txt left in tree.
git status -sb
prints:
## master
DU i1.txt