Chinaunix首页 | 论坛 | 博客
  • 博客访问: 633441
  • 博文数量: 75
  • 博客积分: 7001
  • 博客等级: 少将
  • 技术积分: 1465
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-11 17:39
文章分类

全部博文(75)

文章存档

2010年(1)

2009年(25)

2008年(49)

我的朋友

分类: LINUX

2008-07-30 20:18:56

An Introduction to git
============================================================
good introduction: Randall Schwartz on git
life before git
git as as an prime example of software engineering under Unix
git objects are identified by SHA1 sums!
objects:
  blobs (file contents)
  trees (blobs or other trees)
  commits (tree, parent commits, message)
  tags (object (usally commit), name (2.6.26), message, signature)
  one SHA1 commit describes complete history (uniquely, cryptographically strong)
  Denx git trees and gitweb
  Stacked git
GUI tools:
  gitk
  git-gui
  tig
 
stages: working dir -> index (stage area) git-object db
simple git commands:
introduce yourself:
$ git config --global user.name "Your Name Comes Here"
$ git config --global user.email
 
clone a repository:
$ git-clone git://
 
look at the history
$ git-log
 
add a branch for hacking
$ git-checkout -b hacking HEAD
 
edit some files and look at changes in working dir
$ git diff
 
add modified files to the index:
$ git add file1 file2
 
delete some and mark them as deleted:
$ git rm file3
 
look at diffs of the modified files added to the index
$ git diff --cached
 
get some general statistics of which files were modified:
$ git status
 
to throw away the changes git reset HEAD, to reset the working directory git-checkout -f
commit the changes added to the index (will be prompted for commit message)
$ git commit
 
alternatively without using the index as an intermediate stage:
$ git commit -a
 
unhappy with commit message?
$ git commit --amend
local branches
what branches have we got?
$git branch
 
create a branch as a clone of the current branch:
$ git branch hacking
 
check out the contents of this branch:
git checkout hacking
 
hack around, make a mess of it and decide to throw it away
git checkout -f
git checkout master
git branch -d hacking
remote branches
add a new remote branch
$ git remote add vanilla git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
 
fetch the objects but don't merge
$ git fetch vanilla
 
look at remote branches
$ git branch -r
 
merge one with main kernel branch
$ git-merge vanilla/master
 
goodies:
o whos fault is it: git-blame
o which commit introduced the bug: git-bisect
o maintain a clean repository: git-gc
o check repository for consistence: git-fsck
o remove all those untracked files: git-clean
 
tree too big?
o use a shared repository (objects on demand) git-clone -s
o git-clone --reference : reference a local repository
o make a shallow copy: git-clone --depth
阅读(1415) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~