Git手册

开始学习Git,计划一周,能学完吗?

Git 参考文档目录:

(1) man git      //查看

(2) git help [ ]    // help命令也可以查看


1. git clone

// git-clone command to download a copy of an existing repository

$ git clone url

Tree下面的.git目录包含project所有的历史信息。


2. commit

each version history or snapshots. change history

可以用 $ git show 命令查看。


3. git branch

show the list of branch heads


# an example

$git tag -l     // list all tags

$ git checkout -b new tag

$ git branch

   master

* new


如果你想看另一个版本,你可以修改branch名类似这样:

$ git reset --hard v2.6.17


4. gitk

运行 gitk 命令,能够查看merge commits,以有助于理解git历史。


5. branch: 开发行

branch head (head) : 指代branch上最近的一个commit

         o--o--o <-- Branch A
        /
 o--o--o <-- master
        \
         o--o--o <-- Branch B

对branch的操作命令

git branch:   list所有branch

git branch <branch> : 创建一个新的branch,指向当前branch历史里一样的点;

git branch <branch> < start-point>:

git branch -d <branch>: delete

git branch -D <branch>

git checkout <branch>  : 使当前的branch作为< branch> ,更新工作目录来反应 <branch>的版本。

git checkout -b <new> <start-point>:  创建一个新的branch <new> ,参照对象是< start-point>, 同时check out.

The special symbol "HEAD" can always be used to refer to the currentbranch. In fact, git uses a file named "HEAD" in the .git directory toremember which branch is current:

$ cat .git/HEAD
ref: refs/heads/master

6. origin

origin/man

"origin": 远程配置库,也叫 remote。

如果你想在你自己的branch上构建远程tracking的branch,

$ git checkout -b my-todo-copy origin/todo

Note that the name "origin" is just the name that git uses by defaultto refer to the repository that you cloned from.


7. git fetch

git remote add "branch" "url"

git fetch "branch"

git branch -r  // show all remote branchs


8. 如果你的version 2.6.18工作,而master crash了。你可以通过git bisect命令找到某个commit。

$git bisect start

$git bisect good v2.6.18

$git bisect bad master

Bisecting: 3537 revisions left to test after this
[65934a9a028b88e83e2b0f8b36618fe503349f8e] BLOCK: Make USB storage depend on SCSI rather than selecting it [try #6]



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值