第三章

 

Git是一个开源的分布式版本控制系统,用以有效、高速的处理从很小到非常大的项目版本管理。Linux内核代码及很多的著名项目(Android、eclipse、KDE等)都使用了Linux之父Linus编写的Git进行源代码管理。Git作用是对源代码进行管理。

在Linux下可以直接使用man命令查看指定命令的帮助文档 #man git-checkout

1.git init

Git版本库分为本地版本库和远程版本库。

#mkdir -p /demo/helloworld-git

#cd /demo/helloworld-git

#git init

#ls -al(建立空的版本库)

查看Git文档

在Linux下使用man命令查看指定命令的帮助文档。如果要查询git-checkout命令的帮助文档,执行命令:# man git-checkout(按“q”键退出帮助)。安装git-doc后会安装git的文本格式和HTML格式的文档,所有的文档都存在/usr/share/doc/git-doc目录中。

以文本形式查看指定的文档命令:# git help<sub-command>

查询git-checkout命令的文档命令:# git help git-checkout

查看HTML格式的文档命令:# git help –w git-checkout

2.git commit

在/demo/helloworld-git目录下建立helloworld.txt文件

#cd /demo/helloworld-git

#echo “helloworld” > helloworld.txt

将文件加到本地版本库的索引中,并将helloworld.txt文件提交到版本库

#git add helloworld.txt

#git commit -m ‘helloworld-master’

恢复到最近一次提交的状态:

#git checkout helloworld.txt

3.git branch

显示分支:# git branch

建立分支:# git branch new-branch

4.git checkout

# git checkout new-branch(将当前分支切换到new-branch上)

修改helloworld.txt文件的内容,并重新提交到本地版本库

# echo ‘世界你好’>helloworld.txt

# git add helloworld.txt

# git commit –m helloworld-new-branch

 http://home.cnblogs.com/u/Silence-w/