I have two branches dev
and bugfix
on dev I have created new file TestClass.cs
this file is not staged.
If I run git status
it shows
On branch dev
Untracked files:
(use "git add <file>..." to include in what will be committed)
WebApplication1/TestClass.cs
nothing added to commit but untracked files present (use "git add" to track)
Then I run git checkout bugfix
Now I can see the newly added class TestClass.cs
in this branch as well.
so if I run git status
it shows
On branch bugfix
Untracked files:
(use "git add <file>..." to include in what will be committed)
WebApplication1/TestClass.cs
nothing added to commit but untracked files present (use "git add" to track)
Can someone explain to me this behavior? why this file is being shared between them? I came to know that I should have staged then stash this file before checking out.
But still I want to understand this behavior. Why it's not kept for dev branch only? sometimes I forget to stage and stash changes before checking out and it creates a huge mess