Chinaunix首页 | 论坛 | 博客
  • 博客访问: 822563
  • 博文数量: 222
  • 博客积分: 4341
  • 博客等级: 上校
  • 技术积分: 2155
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-16 13:50
个人简介

...

文章分类

全部博文(222)

文章存档

2019年(1)

2016年(9)

2015年(7)

2014年(14)

2013年(11)

2012年(10)

2011年(6)

2010年(25)

2009年(37)

2008年(21)

2007年(81)

我的朋友

分类: LINUX

2009-12-31 15:42:43

Product Details
Paperback: 328 pages
Publisher: O'Reilly Media; 1 edition (June 4, 2009)
Language: English
ISBN-10: 0596520123
ISBN-13: 978-0596520120


3.Getting Started 

$ git
$ git --version
$ git commit --amend //修订上一次提交的msg
$ git help subcommand
$ git subcommand --help

$ git commit -m "Fixed a typo."   =  $ git commit --message="Fixed a typo."

$ git checkout main.c //检出为main.c的标签
$ git checkout -- main.c //检出名为main.c的文件

Quick Introduction to Using Git 
$ git init /在.git目录下创建一个空的 Git 版本库
$ git add 
$ git commit
$ git status

$ git config user.name "Jon Loeliger" //配置提交者名称
$ git config user.email "jdl@example.com" //配置提交者邮件地址

$ git log //git 日志

$ git show //查看最近一次详细的提交信息 
$ git show 97d65812a53b386831b41fc949ba80ef00b3cdf6 //查看指定提交的详细信息

$ git show-branch //查看版本库的当前分支
$ git show-branch --more=10
$ git git-diff //比较当前的工作目录和版本库数据库中的差异

$ git rm filename //在版本库中删除一个文件
$ git mv filename1 filename2 //在版本库中重命名一个文件

$ git clone //复制一个版本库

相关配置文件
.git/config
~/.gitconfig
/etc/gitconfig

$ git config --global user.name "Jon Loeliger" ==>~/.gitconfig
$ git config --global user.email "jdl@example.com" ==>~/.gitconfig

$ git config -l

$ git config --unset --global user.email //删除一个设定


4.Basic Git Concepts 
blob对象,即文件.注意只包含内容,没有名字,权限等属性(但包含大小)
tree对象,相当于文件夹。所包含的文件(blob对象)/文件夹(tree对象)的名字及其基本属性(比如权限、是否符号链接等)的列表。
commit对象,表示修改历史. commit对象可以视为类似矢量的概念, 由父commit(可能不只一个,合并情形下)指向新的tree对象.子commit的直接父commit,使用“子commit^n“来引用.
tag对象. 可以指向blob, tree, commit并包含签名,最常见的是指向commit的PGP签名的标签.
blob, tree, commit 都是用其存储内容的 SHA-1 值命名的(不是简单的对整个文件取 SHA-1 值),tag 自然使用的是普通名字.

文件存储
.git/objects/3b/18e512dba79e4c8300dd08aeb37f8e728b8dad
$ git cat-file -p 3b18e512dba79e4c8300dd08aeb37f8e728b8dad

文件与目录
$ git ls-files -s //查看当前的git库中有那些文件
$ git write-tree //将暂存区域的内容写到一个 tree 对象
$ git read-tree //将 tree 对象读到暂存区域中去


5.File Management and the Index
Tracked
Ignored
Untracked

$ git add
$ git status
$ git ls-files --stage
$ git hash-object data
$ git commit --all
$ git rm filename
$ git rm --cached filename
$ git mv filename newfilename

.gitignore 文件


6.Commits
$ git log master
$ git show HEAD~2
$ git show origin/master:filename

$ gitk

git bisect //在提交历史中进行二分查找
$ git bisect good
$ git bisect bad
$ git bisect log
$ git bisect reset

git blame  文件标注
$ git blame -L 12,22 filename
$ git blame filename 


7.Branches 
$ git merge-base original-branch new-branch

$ git branch new_branch //创建new_branch分支
$ git checkout -b new_branch //创建并切换到new_branch分支
$ git checkout new_branch //切换到new_branch分支
$ git branch //列出当前所有的分支

$ git show-branch //版本库中分支状态

$ git merge branch //将branch合并回当前分支

$ git branch -d old_branch //删除old_branch分支


8.Diffs 
$ git diff //比较当前与暂存区域的差别

git diff commit //比较当前与commit的差别
git diff --cached //比较暂存区域与版本库的差别
git diff --cached commit //比较暂存区域与commit的差别
git diff commit1 commit2 //比较commit1 与commit2的差别
git diff --stat //对差异信息进行统计



9.Merges
$ git checkout branch
$ git merge other_branch
$ git mergetool //调用可视化的合并工具mergetool



10.Altering Commits 
git-reset
--mixed  默认选项,重置暂存区状态

--soft 将已经提交的东西重新逆转至“已更新但未提交(Updated but not Check in)的状态

--hard  将工作树中的内容和头索引都切换至指定的版本位置中,修改的内容和git add的信息都会被丢弃

$ git cherry-pick commit //只合并指定的commit
$ git revert  commit //回滚代码, 将内容反向修改回去,版本会递增,不影响之前提交的内容

$ git commit --amend //修改最近一次commit的内容,版本不变

$ git rebase //衍合(重新定义分叉点)
$ git rebase -i  commit //修改最近一次commit的内容,版本不变


11.Remote Repositories 
$ git push //远程提交
$ git fetch //远程更新,仅获取,不合并
$ git pull //远程更新,获取并合并


12.Repository Management 

13.Patches 

14.Hooks 

16.Using Git with Subversion Repositories 

Index 

阅读(1259) | 评论(0) | 转发(0) |
0

上一篇:git 学习笔记

下一篇:gitweb configure

给主人留下些什么吧!~~