Reputation: 1837
Fellow coders, today is my first dive into git using Tower on the Mac - life's too short to mess with the command line ;)
I did read a few intros and tutorials but none addressed the question I'm writing about. I'm having some trouble understanding the working directory concept in git vs. SVN.
What I did:
These steps worked.
So far I have not been asked for the location of the working directory and I cannot checkout the master HEAD (the option is disabled). My question is: Is my original folder acting as the checkout working directory? When does the checkout command work? Does it only come to play when I have multiple branches?
Hope someone can clarify this before I go any further.
Upvotes: 2
Views: 8547
Reputation: 530
A slightly shorter answer to your questions:
git checkout
is used to switch between branchesUpvotes: 5
Reputation: 599
Subversion litters your working copy with (hidden) '.svn' folders, which contain metadata and copies of the original data of the checkout. Git puts it's data into a single '.git' folder at the project root.
If you create a new git repository with git init
, you should be able to see this '.git' folder with ls -al
commandline magic (I'm sure Mac OS allows this graphically, too).
Pretty much everything you do with git (except fetch, pull, pull) uses the local repository hidden in the '.git' folder. That's one of the reasons, that makes git so fast. If you had cloned from another repository, you would first commit your changes locally and then push them (at any point you like) back to the 'origin'.
Upvotes: 1
Reputation: 37950
When switching from one source control system to another, one often finds that there are many terms in common, except that some "common" terms actually have different meanings in the two systems. And it becomes even more confusing because git's branching model is quite different from that of SVN. (Warning: my SVN is getting a little rusty, so feel free to correct any errors.)
Working directory has the same meaning: it is the directory where you checked out the repository (or the one where you created a local repo), and where the files you directly work with reside. However, what SVN calls checking out (namely, copying the contents of a remote repository and "linking" your repository to the remote one) is called cloning in git. In git, checking out means to switch to another branch or revision.
In SVN, branching works by "copying" the entire repository to another folder (on the server), and locally, you can checkout the branch (into another working directory, if you want to). So in a sense, a branch is a full repository on its own.
In git, there is only one repository, which contains the entire development history as an acyclic graph of revisions. A revision has one or two parents, and given a revision, any number of revisions may have it as a parent (so many revisions can branch out from one revision, and a revision may be a merge of two revision sequences). At any point in time, you may checkout a specific revision. This operation will make the working directory contents equal to what they were at the time of the specified revision (in other words, it will "replay" all revisions from the initial revision up to the specified one).
What is a branch in git, then? It is simply a label that is attached to a revision. If you check out a branch, you get the effect same effect as if you had directly checked out the branch' revision, but when you commit, the label will automatically move forward to the new revision.
Finally: In SVN, HEAD refers to the "main" branch; in git, it refers to the commit or branch that you have currently checked out.
Upvotes: 9