Information Technology Reference
In-Depth Information
$ git checkout info
$ rm i1.txt
# removed file i1.txt is not present in doc
branch
$ git status -sb
The output would contain the information about one deleted file i1.txt . If you
switch to the doc branch (this branch doesn't contain the i1.txt file) with:
$ git checkout doc
Then, git will not warn you about conflicts. The repository becomes clean and the
information about the deleted file i1.txt is lost. If you switch to the info branch
again the file will be resurrected. In the case of the m2.txt file removed in the recipe
with the $ rm m2.txt command, the information that the file was deleted was pre-
served when we switched to the doc branch. That's because the file m2.txt exists in
every branch.
Question Can you imagine an alias that restrict switching branches only to clean
state?
5-7. Switching branches in a dirty repos-
itory with conflicts
Problem
You just modified the working directory and you want to commit changes in a different
branch. You have to switch to another branch and then create a new revision. In this re-
cipe we consider the case of when your changes collide with the branch you want to
switch to. If that is the case, git doesn't allow you to checkout another branch.
Solution
Clone the repository created in Recipe 5-1:
Search WWH ::




Custom Search