Android深度探索(卷1)HAL与驱动开发第三章读书笔记

l  Git的基本用法

  1. 创建版本库 git init

分为本地版本库和远程版本库,使用Git管理源代码版本时可以不连接Internet,Git直接与本地版本库通信;连接Internet后则与远程版本库通信。

首先要建立一个开源项目的工作目录,并进入

#mkdir –p /demo/helloworld-git

#cd  /demo/helloworld-git

#git init

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

#cd  /demo/helloworld-git

#echo “helloworld”>helloworld.txt

#git add helloworld.txt 提交到文本库

#git commit –m ‘helloworld-master’

#git log 显示日志消息

  1. 创建本地分支 git branch

#git branch 了解当先版本库包含哪些本地分支

#git branch new-branch 创建一个新的分支

#git branch –D new-branch 删除刚建立的分支(在分支所做的一切修改都将会消失)

  1. 切换本地分支 git checkout

本地分支是为了隔离主分支不同部分的修改,使用git checkout命令可以在不同的本地分支之间切换。

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

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

#git add helloworld.txt

#git commit –m helloworld-new-branch 修改文件内容,并重新提交到本地版本库

  1. 上传源代码到GitHub git push

GitHub上传需要SSH校验,所以需要生成一个秘钥文件和公钥文件

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

然后设置密钥,检测密钥设置是否正确

#ssh –T git@github.com

向代理身份验证添加RSA身份

#ssh-add

设置上传者名字和email

#git config –global user.name”YOUR NAME”

#git config –global user.email YOUR EMAIL

设置GitHub上的URI

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

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

#git push –u origin master

查看所有分支

#git branch –a

博客园地址:http://home.cnblogs.com/u/l233ee/

原文地址:https://www.cnblogs.com/l233ee/p/5447354.html