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
阅读(1449) | 评论(0) | 转发(0) |