So, when I'm creating a new class TestClass.cs
in Visual Studio on the test branch, if I don't commit, I am able to see it on every branch, why is that possible?
Asked
Active
Viewed 20 times
0

Foreastbtch
- 65
- 5
-
4The file is not tracked by Git. Changing branch doesn’t affect the file. – Biffen Nov 07 '22 at 13:54
-
So if I have a generic file `file.txt` and is not tracked by git, it won't be affected when switching branches, and it will be the same for all branches? – Foreastbtch Nov 07 '22 at 13:57
-
2Not tracket by git means that is not modified/deleted/restored by changing branches. It is just dangling file and it is not on any branch. If you clone repository into new directory, this file will not be restored since it is not part of history. If you delete it it will be lost and can't be restored by git. – Marek R Nov 07 '22 at 13:59
-
2Is it not only untracked.... it also happens for tracked files that are the same between HEAD and where you want to checkout. If you modify a tracked file and you ask git to checkout, if the modified file is the same between HEAD and where you want to go, the checkout goes on and the file is kept as you have it in the working tree. If that is not the case (file is not the same between HEAD and where you want to go), the checkout fails. Once you commit it (tracked or untracked), it will stop moving around. It is a git feature, in case you think it's a bug. It's very handy. – eftshift0 Nov 07 '22 at 13:59