A place to breathe

Wednesday, February 27, 2013

Learning Git - checking out

Git is a repository system. Like SVN, it stores your file into some server somewhere. Unlike SVN, it is "distributed".

What does "distributed" means? Well, think about if the SVN server fails, where do we pull the source code? It's gone with the server.

With Git, every "checkout" (checkout has a different meaning in Git. Please follow) means you grab the whole repo project. With SVN, usually we just grab sub directory.

So in Git, if the server fails, you still have the entire repo to work with. You can even use your own repo to backup the server, just in case other people didn't checkout the code. That's why the "check out" process is called "clone". So, when you want to checkout a file, you tell Git server that you want to "clone" the whole repo:

git clone "your_repo" .git.

Now, what's next?

In SVN, we usually have trunk, branches and tags. In Git, you also do have trunk, branches and tags (but they call it in slightly different names. We'll see).

It's just that, instead of "checking out" the entire files, you simply "point" the working directory to whatever branches that you want. You can think of having all files in your local.

git branch -a  (this will list all branches in your local and remote) 


To create a new branch, use this:

git branch -b "newfix" 

To checkout to your new branch, simply use: 


git checkout "newfix"

Note that, if your remote has the branch "newfix", checking out the branch "newfix" will create a mirror branch in your local with the exact configuration (files, etc) in your local. Totally cool.



No comments:

About Me

I'm currently a software engineer. My specific interest is games and networking. I'm running software company called Nusantara Software.