这是阅读本书第三章的心得,在第三章种我了解到一款全新的源代码上传与下载的工具Git,它的使用也十分便捷,首先需要安装Git的最新版本# apt-get install git,# apt-get install git-doc git-email git-gui gitk,它的使用也需要很多核心操作比如,查看命令帮助文档# man git-checkout,按q退出,以文本形式查看指定文档# git help <sub-command>查询git-checkout命令文档# git help git-checkout,查看HTML格式的文档# git help -w git-checkout。使用Git首先需要创建版本库:git init(1)使用git clone命令在本地建立一个空的版本库,执行

# mkdir -p /demo/helloworld-git

建立一个开源项目的工作目录,并进入工作目录#cd /demo/helloworld-git,#git init显示隐藏目录# ls -al(2)将文件提交到本地版本库 git commit 执行# cd /demo/helloworld-git,# echo "helloworld" > helloworld.txt进入目录并且在helloworld-git目录下建立一个helloworld.txt的文件,执行# git add helloworld.txt,# git commit -m'helloworld-master'将helloworld.txt文件加到本地版本库的索引中,并将helloworld.txt文件提交到版本库。再就是创建本地分支使用# git branch 查看当前版本库包含那些本地分支使用#gitbranch new-branch建立一个新的分支,删除给该建立的分支# git branch -D new-branch,切换本地分支 git checkout使用# gitcheckout new-branch将当前本地分支区切换到new-branch上,修改helloworld。txt文件容并重新提交到本地版本库

# echo"世界你好" > helloworld,txt

# git add helloworld.txt

#git commit -m helloworld-new-branch

这下就需要在GitHub上创建开源项目,使用之前需要注册一个免费的用户,使用用户登录进入GitHub的首页,点击New repository创建一个新的项目。上传源文件到GitHub git push,备份文件# ssh-keygen -t rsa -c “helloworld@126.com”,紧接着需要了解一些可能用到的操作使用git remote命令设置helloworld工程在GitHub上的URI

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

使用# git push -u origin master将文件上传到GitHub

查看所有分之# git branch -a

从GitHub下载源代码 git clone  # git clone git@github.com:androidguy/hellowrld.git

只想获取某一分支的最新内容  # git pull origin master

posted on 2016-04-27 13:04  花糜海棠  阅读(103)  评论(0编辑  收藏  举报