Wednesday, 21 August 2013

Prevent an untracked file from being overwritten in Git

Prevent an untracked file from being overwritten in Git

Say I have 2 branches master and b2. In the specific directory where the
git repository is, there are many files not tracked by git and some that
are tracked by git. I did some work in branch b2, and now I tried to
switch back to master using
git checkout master
I get an error saying
The following untracked working tree files would be overwritten by checkout:
queries.py
I have two questions: (1) I don't get this message for other untracked
files, why for this specific file? (2) I want this file to remain the
state it currently is across the different branches (that is, I do not
want to overwrite or delete it). How can I do that?
I looked at other questions that mentioned this error. The answers
suggested using git clean saying it would remove the untracked file. But I
don't want to remove it.
Thank you.

No comments:

Post a Comment