Git resets your working directory to look like the snapshot of the commit that the branch you check out points to.
But it's very easy to make a mistake here. If you don't commit the changes in your new branch and instead check out another branch, those changes will be there too. I've seen this cause confusion with developers. So if you make a local branch off your "develop" line:
git checkout -b NewBranch develop
and make some changes to files, you have to commit those changes to "NewBranch" or you'll still see them as modified files if you switch back to the "develop" or "master" branches. Now if you commit those changes to NewBranch line first, then checkout "develop," you won't see them as modified, and the files will instead be in their state from the "develop" branch.
Happy Local Branching!
No comments:
Post a Comment