I had an SVN background before and I get used to working between branches alternatively as a charm with it.
however, when I was trying to get myself familiar with GIT, I only found this VC work differently in the above-mentioned aspect.
for example.
in GIT. I initially created a branch called “Master”.
master
======
car.rb
Then, I branched out into a new branch “new_branch”.
new_branch
==========
car.rb
airplane.rb
from this point, I continued working on my recently added class “airplane.rb” so on and so forth. and then added it to the index.
and finally I needed to switch back to work on the master branch again.
what I only found when I did so was in the branch “master”, the newly added file from “new_branch” was still there. so, I got no idea how to work with at that moment.
what do you normally do when it comes to switching between branches very often like my case?
any advice would be very much appreciated!
You put
airplane.rbin your staging area, which means it’s not committed yet. When switching branches, git will keep your staging area intact, so that’s why you still see it when going back to master.You need to commit your changes when you are ready to do so, as the staging area is just… staging! It allows you to prepare the commit, but if you don’t commit the changes aren’t controlled.