In my branch A, I created a new directory myDir. I commited all changes on that branch by git add . and commit. I don't see any untracked file or directory.
Then I switch to branch B, I see untracked file myDir.
How can I remove myDir from branch B but still have it when switch to branch A ? I mean I don't want to really delete myDir from hard disk and I don't want to see untracked file myDir either on branches (other than branch A) .
I know there is git clean command, but it deletes files from hard disk, right?
There is no real problem removing
myDirfrom your disk, when you will switch back to branch A,myDirwill appear again.So you can safely use
git clean(in this case, since you already committedmyDiron another branch).