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.