On 17 Sep 2014 17:29, "Dmitry Moscow" <[email protected]> wrote: > > I come from an SVN background, and I have a hard time grasping Git's philosophy. In particular, I'm confused by the following. > > Imagine I have made some changes in my working dir. If I switch to another branch, the changesremain, which is very unusual, from an SVN point of view. This means that uncommitted changes areshared between the branches. Moreover, the "stage property" of the files is also shared between the branches: if I call git add * in one branch, then all the files will be added to next commit in all the branches. Looks like my branches differ only by already committed files.
Branches are actually just pointers to commits, so yes, they differ in that. > > So, if uncommitted data are shared, then, no matter which branch I am on now, I will commit all the staged files, even if they were added in different branches! As I come from an SVN background, this strikes me as very odd. You should understand that while in SVN, committing has one step (svn add immediately commits your files), git does the same in two: you add your changes to the staging area (think of this as a pre-commit area), then do the actual commit. In SVN, you tell the VCS »commit this, this and this file«. With Git, you write list of the changes (»commit the changes of this file, commit this line from this file«), then, when you think your list is fine, you give your paper (the staging area) to the VCS. > > Am I correct, or am I just confused? Why does Git work in this way? > > Sometimes, Git tells me something like this: >> >> Cannot switch to another branch because your changes will be erased. Commit them first. > > In SVN, that's not a problem: branches are independent. Why and when does this happen in Git? AFAIR, branches in SVN are actually two separate directories, with — initially — the same files, and branching itself is an actual commit. In Git, as I said before, a branch is merely a pointer to a commit, thus, your source tree doesn't change due to branching. > > What's up with the way Git handles folders? If I create a new folder, it is not displayed in Git's status report. Does Git simply not care about folders? > > -- > You received this message because you are subscribed to the Google Groups "Git for human beings" group. > To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. > For more options, visit https://groups.google.com/d/optout. All in all, you should stop comparing SVN and Git, they differ in too many things. [1] is somewhat old and unmaintained, but I still suggest you to read it. I hope others may post some similar or better artices. [1] http://git.or.cz/course/svn.html -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
