views:

477

answers:

2

I'm trying to get started using git, but I'm having some troubles right away. I'm using Git GUI for Windows. Keep in mind I've never used version control before and don't really know how it works.

What I have is a Code::Blocks C project in a folder on my laptop's hard drive. I opened Git and created a new repository on a USB hard drive. I figured, I could create a branch, which led to the already-existing directory of my project, and then commit all the code in it to the repository. Then every time I wanted to work on this project, I could check out my code, open up the Code::Blocks project and edit. And then get into different branches and stuff, you know, all that jazz.

So I created this repository, and went to create a branch from the menu. I got this dialog, which asked me for either a branch name, or to "Match Tracking Branch Name (whatever that means)." Then, under "Starting Revision," it has a few options. One is "Revision expression" next to a text box, and no matter what I enter it is an invalid revision expression. So I tried the other options, "Local Branch," "Tracking Branch," and "Tag." These enable another text box, but even if "Revision expression" isn't selected, it still says I have entered an invalid one. What is a revision expression? How do I just, check out code, to a directory on my hard drive?

Oh, and then, there is an "Options" section with "Update Existing Branch: [ ] No [x] Fast Forward Only [ ] Reset,"
and two check boxes, "Fetch Tracking Branch" and "Check Out After Creation (this one is obvious)." What do all of these mean? What's a tracking branch? What does "Fast Forward Only" and "Reset" refer to? I have no idea what I'm doing or what I've gotten myself into.

+3  A: 

I'm a little confused about what you're trying to do.

First of all, if your code is on your laptop, then why are you creating a repository on your USB drive? With git, unlike CVS or SVN, the repository always exists in your project's root directory.

Here's what I think you want: Create a new git repository on your laptop hard drive at the root of your C project. Then check the files in to the repository and commit. Now you want to create a branch so you can add color to all the dialog boxes (for example), so you create a new local branch called "color-dialogs". You're not tagging and you're not tracking. Tagging is what you do when you release version 1.0: you mark a particular revision as "1.0" so you can go back to it. Then later you make a "1.1" or "2.0" tag. Tracking is what you do when you want your branch to be the same as someone else's. For example, I want my project to have all the latest color dialog boxes so I track your branch named "color-dialogs" but I don't call it that, I just call my branch "master" because I don't care about the old black and white dialogs. Whenever I do a pull from your repository, since I'm tracking your "color-dialogs" branch, I'll pull in all the updates you've made to that branch.

Fast-forwarding is when you pull updates to a branch that you haven't made changes to.

So a summary: create the repository on your laptop HD in your project folder. Create local branches if you want in there, and you can switch back and forth between branches at the touch of a button (using git checkout). If you want a repository on a different drive, what you do is you clone the repository from your internal HD to your USB stick. Then you can pull changes from one repository to the other (each is a complete standalone repository).

Dietrich Epp
Well I created a repository in the working directory of my project... But, I don't know what that means. What's the point of the repository being right where I'm working on the project files. How would I create a new branch and make new revisions with that? Do I just end up with a new folder for every branch I create with git? What is a revision expression?
Carson Myers
+1  A: 

I have only skimmed through The Git Parable mentioned at Simon Edwards' blog post, but it looks very promising in getting a nice conseptual overview without too much details, so I would reccomend reading it for learning git. It is high on my "to read" list, even if I have been using git for some time.

hlovdal