0

I'm in transition phase, from TFS to Git. I use Source tree for commits.

I added two new class libraries to my solution - CMS.Core, CMS.Data

I pushed changes in the main web project. None of the CMS.Core or CMS.Data projects are pushed to master or committed.

Now I create a new branch for my sprint named Sprint 20. I'm expecting none of those new projects are pushed to the server. I've checked the code in the git server and they're not there.

Now I switch my working branch to the new branch but I still have those two newly added projects there. Since I created this branch from master, which didn't have those projects, I'm wondering how those two projects are still in my solution.

I've checked the project file in notepad++ and there's NO reference to those projects. Does this mean even if I switch branches, the files will still be there even if it wasn't in the master?

A.Suv
  • 3
  • 2

1 Answers1

0

None of the CMS.Core or CMS.Data projects are pushed to master or committed.

Here is something i assume you are not aware of:

Git has something called 3-states.

enter image description here

The 3 states are described above.


A full and complete answer is here: git checkout carries unstaged files to the new branch

Here is the short summary for you.

The missing part

The working directory and the staging are are SHARED between all your branches (* - there is a way to bypass it and to have clean 3 states per branch with stash or worktree) More info about worktree is here

But in your case the working directory and the staging are shared so when you "move" between branches all the none commited content will remain there unless you handle it.


Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • So the branches are logical and doesn't matter which branch I switch to, I have same set of physical files ? – A.Suv May 17 '16 at 23:46
  • Not exactly. Only the modified/ new files will be shared. if there is a file which is commited and its part of the branch it will be added to the working directory once you switch to this branch. But if this file is not part of the second branch it will not be in your working directory unless you modified it. – CodeWizard May 17 '16 at 23:48
  • The rule is simple: all the un-tracked, modified/ deleted files will be displayed with the status command, the rest of the files will not popup in the status – CodeWizard May 17 '16 at 23:50
  • Untracked files are not in control of Git, hence it can't remove it for me when I switch branches ? – A.Suv May 18 '16 at 01:03
  • Unchecked files are files which git has no history about them. when if they are tracked git will not remove them when you switch branch. You can use the `git clean`, 'git reset', 'git worktree' & `git stash -u` to "remove" those files out of your way form the working directory. – CodeWizard May 18 '16 at 01:14