天天看点

github使用介绍

Git支持多种协议,默认的

git://

使用ssh,但也可以使用

https

等其他协议。

使用

https

除了速度慢以外,还有个最大的麻烦是每次推送都必须输入口令,但是在某些只开放http端口的公司内部就无法使用

ssh

协议而只能用

https

使用https:

git clone https://[email protected]/Tenderrain/gitskills.git

需要输入github注册用户对应的密码

使用ssh:

git clone [email protected]:Tenderrain/gitskills.git(#me:域名后面是冒号)

不需要输入密码

HEAD指向分支(指针),分支指向提交!

git log --graph --pretty=oneline --abbrev-commit

--abbrev-commit   只保留commit id 的前几位

--pretty=oneline  去除Author、Date等信息,只保留commit信息

--graph

           可以看到分支合并图

分支合并

使用Fast-forward

git merge dev      

提示Fast-forward

信息,Git告诉我们,这次合并是“快进模式”,也就是直接把

master

指向

dev

的当前提交,所以合并速度非常快。如图

当然,也不是每次合并都能

Fast-forward

,我们后面会将其他方式的合并。通常,合并分支时,如果可能,Git会用

Fast forward

模式,但这种模式下,删除分支后,会丢掉分支信息。如果要强制禁用

Fast forward

模式,Git就会在merge时生成一个新的commit,这样,从分支历史上就可以看出分支信息。

不使用Fast-forward

git merge --no-ff -m "merge with no-ff" dev