g Text Version
Beauty & Self
Books & Music
Food & Wine
Health & Fitness
Hobbies & Crafts
Home & Garden
News & Politics
Religion & Spirituality
Travel & Culture
TV & Movies

Bored? Games!
Take a Quiz
Rate My Photo

Autism Spectrum Disorders
Mental Health
Blogs / Social Networking
Kidney Disease
Today in History

All times in EST

Clairvoyance: 08:00 PM

Full Schedule
g Computer Careers Site

BellaOnline's Computer Careers Editor


Setting Up Your First Git Repository

Guest Author - Julie L Baumler

The first thing you need to do is install and configure git on your machine. If you are running windows, my earlier article Installing Git On Windows explains how to do this. You can find OS X installers for git here. For Linux and Unix, your local package management tool (pkgadd, yum, dpkg, rpm, etc) likely has access to a git package, if it isn't already installed. Finally, you have the option of installing from source. The git source is available here (see my article Installing Linux and Unix Software From Source if you need help with installing from source.)

You will need ssh keys if you want to upload code to repositories that use ssh authentication, such as Git Hub. If you do not already have an rsh public key, create one using ssh-keygen. (This command is available in the Git Bash shell that is part of msysGit and is installed by default on OS X and most Linux and Unix systems.) You can just pick all the default options. Remember where ssh-keygen puts your public key (id_rsa.pub) so that you can retrieve it when you need it. (Most likely the .ssh directory in your home directory.)

Next, you should configure your git client so that it knows who you are (your name and email address.)

git config --global user.name "First Last"
git config --global user.email "me@example.com"

(Note: If you use more than one email address or multiple nom de codes that you want to use, it is possible to set these to different values for specific projects.)

Next, create a local directory to hold your code. On Unix-like operating systems /usr/local/src or $HOME/src are conventional. For Windows, I recommend c:\code. But you can use anything you like.

Move to your code directory. Now you can create your first git repository named "test".

git init test

This creates a directory named "test" containing only the files necessary to manage git.

You can add files to this directory using your favorite text editor, development environment, or the file manager. For the purpose of this tutorial, create a file called "README" that explains what your project is about. Next you need to tell git about the file with:

git add README

(Note: you'll need to be in the test directory for this to work.)

Now you can look at your repository using git status and see the file:

git status
# On branch master
# Initial commit
# Changes to be committed:
# (use "git rm –cached ..." to unstage)
# new file: README

At this point, git knows about the file, but it isn't officially part of the repository. To officially add the file to git, you need to use:

git commit -C 'Initial Version' README

The string after the -C is a comment that describes what the code is for or what changes have been made. You can review changes later by looking at these comments. Now if you look at git status it will show no changes to be committed. Now that your code (or in this case README file) is committed, you are free to take advantage of all the features of a version control system – edit files and revert them, share your archive, etc.

Git Magic at Amazon.comBuy Ben Lynn's book Git Magic from Amazon.com or download a copy using git clone git://repo.or.cz/gitmagic.git
Pragmatic Version Control Using Git (Pragmatic Starter Kit) at Amazon.comBuy Travis Swicegood 's book Pragmatic Version Control Using Git (Pragmatic Starter Kit) from Amazon.comor check out a preview here

Add Setting+Up+Your+First+Git+Repository to Twitter Add Setting+Up+Your+First+Git+Repository to Facebook Add Setting+Up+Your+First+Git+Repository to MySpace Add Setting+Up+Your+First+Git+Repository to Del.icio.us Digg Setting+Up+Your+First+Git+Repository Add Setting+Up+Your+First+Git+Repository to Yahoo My Web Add Setting+Up+Your+First+Git+Repository to Google Bookmarks Add Setting+Up+Your+First+Git+Repository to Stumbleupon Add Setting+Up+Your+First+Git+Repository to Reddit

Installing Git on Windows
Installing Linux and Unix Software From Source
Computer Careers Shops
Related Articles
Editor's Picks Articles
Top Ten Articles
Previous Features
Site Map

For FREE email updates, subscribe to the Computer Careers Newsletter

Past Issues

Printer Friendly
tell friend
Tell a Friend
Email Editor

Content copyright © 2015 by Julie L Baumler. All rights reserved.
This content was written by Julie L Baumler. If you wish to use this content in any manner, you need written permission. Contact Maria S. Cuasay for details.


g features
Get Hip to Hybrid Medical Tech Careers

Front-End Developer An In Demand Career

Can You Be An IT Project Manager?

Archives | Site Map


Past Issues

Less than Monthly

BellaOnline on Facebook

| About BellaOnline | Privacy Policy | Advertising | Become an Editor |
Website copyright © 2015 Minerva WebWorks LLC. All rights reserved.

BellaOnline Editor