第三章读书笔记

第三章

 

Git作用是对源代码进行管理。

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

 

基本用法

1,创建版本库:git init

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

#mkdir -p /demo/helloworld-git

#cd /demo/helloworld-git

#git init

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

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

使用git checkout master 和 git checkout new-branch来回切换本地版本库。

5,在GitHub上创建开源项目

6,上传源代码到GitHubgit push

需要在~/.ssh目录中生成一个密钥文件(id_rsa)和一个公钥文件(id_rsa.pub

# ssh-keygen -t rsa -C ”helloworld@126.com”

7,从GitHub下载源代码:git clone

 

Linux内核完全是使用Git管理的。

 

 http://www.cnblogs.com/875825a/

 

posted @ 2016-04-20 13:41  lows  阅读(85)  评论(0编辑  收藏  举报