第三章 心得体会

通过第三章的学习,知道了什么是Git和为什么使用Git。也让自己完成了Git发安装和一些相关的操作。

学到的知识:

安装Git

1、# apt-get install git

2、# apt-get install git-doc git-svn git-email git-gui gitk

查看Git文档

1、查询git-checkout 命令的帮助文档,使用命令:# man git-checkout

2、查询git-checkout 命令的文档,使用命令:# git help git-checkout

3、查询HTML格式的git-checkout 命令的文档,使用命令:# git help -w git-checkout

源代码的提取和获取

1、创建版本库: git init

1.建立一个开源项目的工作目录,并进入工作目录

# mkdir -p /demo/helloworld-git

# cd  /demo/helloworld-git

2.执行命令

# git init

2、将文件提交到本地版本库:git commit

1.进入/demo/helloworld-git 目录,并建立一个helloworld.txt文件

# cd /demo/helloworld-git

# echo “helloworld”>helloworld.txt

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

# git add helloworld.txt

# git commit -m ‘helloworld-master’

3.显示日志记录

# git log

恢复文件

# git checkout helloworld.txt

3、创建本地分支:git branch

1.查看分支

#git branch

2.建立一个新分支

#git branch new-barnch

3.删除刚建立的新分支

#git branch -D new-barnch

4、切换本地分支:git checkout

1.将当前本地分支切换到new-barnch

#git checkout new-barnch

5、GitHub上创建开源项目

6、上传开源代码到GitHubgit push

1.备份密匙文件和公匙文件

# ssh-keygen -t rsa -C xxxxx@126.com

2.检测密匙和公匙

# ssh -T git@github.com

3.向代理身份验证添加RSA身份 # ssh-add

4.设置上传者的姓名和email

# git config --global user.name”Your Name” 

# git config --global user.email helloworld@126.com

5.设置helloworld工程在GitHub上的UPI

# git remote add origin git@github.com:androidguy/helloworld.git

6.将本地版本库中的文件上传到GitHub

# git push -u origin master

7.查看所有分支

# git branch -a

7、GitHub下载源代码:git clone

1.下载整个工程

# git clone git@github.com:androidguy/helloworld.git

2.获取某一支的最新内容

# git pull origin master

posted @ 2016-04-28 19:40  奶嘴小王子  阅读(221)  评论(0编辑  收藏  举报