Git Quick Start

Git is...

Git is a free & open source, distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Every Git clone is a full-fledged repository with complete history and full revision tracking capabilities, not dependent on network access or a central server.Branching and merging are fast and easy to do.

Git is used for version control of files, much like tools such as Mercurial, Bazaar, Subversion, CVS, Perforce, and Team Foundation Server.


Creating and Commiting

$ cd (project-directory)
$ git init
$ (add some files)
$ git add .
$ git commit -m 'Initial commit'


Cloning and Creating a Patch

$ git clone git://github.com/git/hello-world.git
$ cd hello-world
$ (edit files)
$ git add (files)
$ git commit -m 'Explain what I changed'
$ git format-patch origin/master


Basic Commands

$ git status
$ git log


The basic Git workflow goes something like this:

1. You modify files in your working directory.
2. You stage the files, adding snapshots of them to your staging area.
3. You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.













Set Up SSH Keys

~$ cd .ssh
/home/bambreeze/.ssh
.ssh$ ll
total 4.0K
-rw-r--r-- 1 bambreeze bambreeze 1.3K 2011-08-09 21:55 known_hosts
.ssh$ ssh-keygen -t rsa -C "bambreeze@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/bambreeze/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/bambreeze/.ssh/id_rsa.
Your public key has been saved in /home/bambreeze/.ssh/id_rsa.pub.
The key fingerprint is:
...
The key's randomart image is:
...
.ssh$ ls
id_rsa  id_rsa.pub  known_hosts
.ssh$ vim id_rsa.pub
.ssh$ ssh -T git@github.com
Hi bambreeze! You've successfully authenticated, but GitHub does not provide shell access.


Create A Repository @ GitHub

ldd3$ pwd
/home/bambreeze/workspace/git-space/ldd3
ldd3$ ll
...
ldd3$ git init
Initialized empty Git repository in /home/bambreeze/workspace/git-space/ldd3/.git/
ldd3$ git add .
ldd3$ git status
...
ldd3$ git commit -m "initial commit for Linux Device Driver (3rd) examples"
Created initial commit ec142ce: initial commit for Linux Device Driver (3rd) examples
 99 files changed, 13387 insertions(+), 0 deletions(-)
...
ldd3$ git status
# On branch master
nothing to commit (working directory clean)
ldd3$ touch README
ldd3$ vim README
ldd3$ git add README
ldd3$ git status
# On branch master
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       new file:   README
#
ldd3$ git commit -m "adding README file for LDD3-Examples project"
Created commit 40db767: adding README file for LDD3-Examples project
 1 files changed, 2 insertions(+), 0 deletions(-)
 create mode 100644 README
ldd3$ git remote add origin git@github.com:bambreeze/LDD3-Examples.git
ldd3$ git push origin master
Counting objects: 123, done.
Compressing objects: 100% (121/121), done.
Writing objects: 100% (123/123), 100.69 KiB, done.
Total 123 (delta 46), reused 0 (delta 0)
To git@github.com:bambreeze/LDD3-Examples.git
 * [new branch]      master -> master


参考文献

1. http://git-scm.com/

2. http://progit.org/book/

3. https://github.com/

posted @ 2011-08-10 07:20  bambreeze  阅读(187)  评论(0编辑  收藏  举报