2

I'm getting some strange behavior from git. Previously, if I made some changes on branch_A, did not commit, and tried git checkout branch_B, I got a warning to commit or stash my changes first, and then after I did so, I could checkout branch_B and it worked fine.

All of a sudden, this has stopped working, in a number of distressing ways. Here is what I mean:

I have uncommited changes on branch A, e.g.


(venv) Georges-MacBook-Pro% git branch
* branch_A
  branch_B
(venv) Georges-MacBook-Pro% git status
On branch branch_A
Changes to be committed:
  (use "git reset HEAD ..." to unstage)

    modified:   file1.py

Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)

    modified:   file2.py

Untracked files:
    ...

(venv) Georges-MacBook-Pro% git diff
diff --git a/file2.py b/file2.py
index 62a513c..da6dbc5 100644
--- a/file2.py
+++ b/file2.py
@@ -33,7 +33,7 @@ def foo():

 @pytest.fixture
 def foo():
-    f = "old_string"
+    f = "new_string"
     return f

so when I try to do this, it shouldn't work, but it does:


(venv) Georges-MacBook-Pro% git checkout branch_B
M   file1.py
M   file2.py
Switched to branch 'branch_B'
Your branch is up-to-date with 'origin/branch_B'.

and git status and git diff look exactly the same. Which they undoubtedly should not.

I'd really appreciate any insight into what I screwed up and how to fix it. I'm relatively new to git and I haven't done much besides the very basic pull push checkout -b.

gmoss
  • 1,019
  • 5
  • 17
  • I should mention that I made a new clone of our repo and the problem did not persist there, but I'm keeping the bad one around for now in case someone has any insight into what to check. Maybe it'll be useful to someone else who runs into this problem. – gmoss Apr 06 '16 at 23:29
  • `git checkout --force branch_B` switches the branch w/o asking, but it also overwrites the changes – Jiri Kremser Apr 06 '16 at 23:48
  • This looks like the answer to your question http://stackoverflow.com/a/22055552/1594980 – Jiri Kremser Apr 06 '16 at 23:52

0 Answers0