Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens to local code when we try to switch the branch in the sourcetree?

I am using source tree, and having to branches local and master, when i switch the branch from local to master , and opened the solution using visual studio i found some files were missing , I am not sure what happens to local code when we switch the branches, please help me on this.

like image 258
Vivek Avatar asked Sep 03 '15 06:09

Vivek


2 Answers

When you switch a branch, all files that are under control of Git will be replaced with the state of the new branch. That includes changes to files as well as additions and deletions.

Note that this is a normal Git feature and doesn't have anything to do with Sourcetree (the UI simply executes a git co command in the background)

In your case this means that you have some files in your current 'local' branch that simply do not exist in the master. You could get them there by merging your 'local' branch into the master branch.

The files are "hidden" by Git and can be revealed by switching back to your branch.

like image 84
reto Avatar answered Nov 01 '22 00:11

reto


The changes in your code will be stored in your branch and whenever you switch again to the old branch you can get your codes. In general if you want to switch between branch you just commit and merge it with master always.

Hope your problem sloved

like image 23
Cse coders Avatar answered Oct 31 '22 23:10

Cse coders