git是Android的版本控制工具,相比cvs而言git更具优势,主要区别有如下2点:
1:git存储的是文件,而不是存储文件之间的差异;
2:分布式存储
所以要学习Android系统开发就必须熟悉git的使用,今天是把我这段时间的学习过程及经验写下来,免得又选择性失忆了。
(((石头与佛像的区别在于佛像是经过打磨而成的,而这个过程很漫长,很痛苦)))
至于安装就不想多说了,我也不会,直接正题吧,git的使用必须先初始化,就是设置用户名和电子邮件什么的。
一:设置电子邮件及用户名
#git config --global user.name "Name"
#git config --global user.email test@63.com
上面是设置全局电子邮件和用户名,实际上还可以为每个版本库单独设置,如下:
#cd 。/pathofrepo/
#git config user.name "Name"
#git config user.email test@63.com
二:初始化一个新的版本库
#mkdir /pathofnew //pathofnew是新的版本目录名
#cd /pathofnew
#git init
执行成会提示:Initialized empty Git repository in /pathofnew/.git/
三:克隆版本库
#git clone <repository url>
四:把目录中的内容纳入版本控制
#cd /pathofrepository
#git init //提示:Initialized empty Git repository in /path/to/existing/directory/.git
#git add .
#git commit -m "initial import of some project"