0

My IDE is showing me the same files in all branches. Even if I create a new class in branch "A" when I checkout branch "B" the class is there.

I haven't committed or pushed anything. My IDE is PhpStorm.

Any idea?

1615903
  • 32,635
  • 12
  • 70
  • 99
  • Yep, that's what I'd expect if you haven't committed anything. You have to tell Git about files if you want it to start tracking them. `git status` will probably tell you that all your files are unmanaged. – trent Oct 31 '17 at 13:41
  • Possible duplicate of [Adding files to a GitHub repository](https://stackoverflow.com/questions/7555551/adding-files-to-a-github-repository) – trent Oct 31 '17 at 13:44
  • _"I haven't committed or pushed anything"_ - there's your problem. You have not actually changed any branch, you just have some changes in your working tree. – 1615903 Nov 01 '17 at 04:33

1 Answers1

0

This is because the new class (such as class.php) is untracked by git repo.

When you created the new class class.php in branchA, but it was not committed in branchA. When you switched to branchB, the untracked file class.php will always show in working directory no matter which branch you checkout.

If you want the class.php only version controlled in branchA, you just need to switch to branchA and commit the changes:

git checkout branchA
git add class.php
git commit -m 'add class.php in branchA' 

Now when you switch to branchB again (git checkout branchB), you will find the class.php will disappear.

Marina Liu
  • 36,876
  • 5
  • 61
  • 74