第三章:Git使用入门

第三章:Git使用入门

安装Git

# apt-get install git

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

 

查看Git文档

查询git-checkout命令的帮助文档

# man git-checkout

以文本形式查看指定的文档可以使用下面的命令

# git help<sub-command>

如果想查看HTML格式的文档

# fit help -w <sub-command>

 

源代码的提交和获取:

1.创建版本库:git init

# mkdir -p /demo/helloworld-git

# cd /demo/helloworld-git

# git init

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

# cd /demo/helloworld-git

# echo “helloworld” > helloworld.txt

# git add helloworld.txt

# git commit -m ‘helloworld-master’

# git log

3.创建本地分支:git branch

# git branch(了解当前版本库中半酣了那些本地分支)

# git btanch new-btanch(创建新分支)

# git branch -D new-branch(删除刚建立的分支)

4.切换本地分支:git checkout

# git checkout new-branch(将当前本地分支切换到new-branch

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

# git add helloworld.txt

# git commit -m helloworld-new-branch

5.GitHub上创建开源项目

6.上传源代码到GitHub: git push

# ssh-keygen -t rsa -C “helloworld@126.com”(备份)

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

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

# git remote add origin git@github.com:androidguy/helloworld.git(设置GitHub上的URL)

# git push -u origin master(上传)

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

# git clone git@github.com:androidguy/helloworld.git(下载整个工程)

# git pull otigin master(获取某一分支)

 

posted @ 2016-04-27 11:37  IT_C  阅读(129)  评论(0)    收藏  举报