笔记二则:
1. 服务器版本下载:
repo init -u git@192.168.1.11:i700t_60501010/platform/manifest.git -b froyo_almond -m M76XXTSNCJNLYA60501010.xml
repo sync
repo forall -c git checkout --track origin/i700t_60501010 -b [你的本地分支]
或者:
git clone git@192.168.1.11:6120_gingerbread/Arm9-6120.git
git checkout --track origin/arm9_6120 -b [你的本地分支名]
2. 服务器新加仓库同步:
请按如下步骤取得Lanucher_wpon的代码:
1:~> cd I700T/.repo/manifest
2: I700T/.repo/manifest> git pull --rebase
3: I700T/.repo/manifest> cd ../..
4: I700T> repo sync platform/packages/apps/Launcher_wpon
5:I700T> cd packages/apps/Launcher_wpon
6:I700T/packages/apps/Launcher_wpon>
7:git checkout --track origin/froyo_almond -b [你的本地分支]
3. 上传本地修改到服务器
repo forall -c git pull --rebase
和服务器同步(要上传代码前,一般先进行此操作)
git add .
或git add 文件名
添加当前仓库修改的文件
git commit -m "..."
在引号中添加你的修改记录
git push origin
本地分支名:froyo_almond
上传本地修改的代码
4. 设置一些默认的全局变量,对所有工程代码有效
git config --global user.name yourmail
git config --global user.email yourmail
git config --global push.default tracking
这样后续git push 后面不用带参数
5.查看修改记录
git log
本地仓库修改记录
repo forall -c git log --since="2011-04-19" --until="2011-04-21"
按条件查看工程所有仓库修改记录
repo status
查看工程中所有仓库的修改状态(包括文件位置)
git status
查看仓库修改状态
6. 分支相关
git branch
查看本地branch
git branch -r
查看远程branch
git branch -a
查看所有branch
git branch -D
(-d)
(branch name)
删除branch
cat .git/config
可以查看本地branch一些信息
7. 修改恢复相关
git checkout filename1
filename2
...
取消本地修改,和服务器同步
git stash
git stash apply
先stash本地修改,然后执行git pull --rebase同步,最后再APPLY恢复自己的修改
git reset --soft head_commit
恢复到最后一次commit,保持代码修改
git reset --hard commit
恢复到指定一次commit,放弃之前所有修改#回退a.py这个文件的版本到上一个版本
git reset HEAD^ a.py
git reset commitNO filename
8. 本地某仓库出问题了,不好闹腾时,删除之,并重新同步跟踪
project_folder/vendor/qcom$ rm -rf proprietary/
进到相应目录,删除之
project_folde$ repo sync platform/vendor/qcom/proprietary
重新repo sync,后面路径名称可查看: gedit .repo/manifest.xml
git branch -a
----列举所有BRANCH
git branch -D 700_arm11_server
git branch -D 700_arm11_server_wifi
--删掉所有本地branch
git checkout --track origin/froyo_almond -b 700_arm11_server
然后track远程branch,重新创建本地分支
9.tag的使用
git tag [tag_name] [version],在对应版本上(一般用change的SHA1),创建tag
git tag -l 列出当前tag
git tag -d [tag_name] 删除tag
有了tag以后,可以使用git checkout [tag_name] -b [branch_name]来检出对应tag时刻的代码。也可以用tag name来实现diff等功能。
10. patch的使用
git diff filename1 filename2 ...
修改位置对比,查看源码
git diff > xxx.patch
将修改的地方打成一个patch
git apply xxx.patch
将patch打上
11. 后续有用到的命令继续添加
git revert 是撤销某次提交。git reset --hard,才是退回到以前的版本
git reset --soft commitNum
保存代码修改的reset,但这个时候无法使用git diff 进行比较修改的文件,必须:
git reset filename filename
这样就可以git diff查看
git diff ffd98b291e0caa6c33575c1e
f465eae661ce40c9 b8e7b00c02b95b320f14b625
663fdecf2d63e74c 查看某两个版本之间的差异
git diff ffd98b291e0caa6c33575c1e
f465eae661ce40c9:filename b8e7b00c02b95b320f14b625
663fdecf2d63e74c:filename 查看某两个版本的某个文件之间的差异
$ git config --global alias.co checkout // co将会成为checkout的别名
$ git config --global alias.br branch
$ git config --global alias.ci commit
$ git config --global alias.st status
$ git config --global user.name "username"
$ git config --global user.email username@mail.com
笔记三则:
1. 下载 repo 的地址: http://android.git.kernel.org/repo ,可以用 wgethttp://android.git.kernel.org/repo 或者 curl http://android.git.kernel.org/repo >~/bin/repo
来下载 repo , chmod a+x ~/bin/repo
2. 用repo sync 在抓去 android source code 的时候,会经常出现一些错误导致 repo sync 中断,每次都要手动开始。 可以用如下的命令,来自动重复:
$?=1;
while [ $? -ne 0 ] ; do
repo sync ; done
3. repo help [ command ] , 显示command 的详细的帮助信息内容
repo init -u URL ,
在当前目录安装 repository ,会在当前目录创建一个目录 ".repo"
-u 参数指定一个URL, 从这个URL 中取得repository 的 manifest 文件。
repo init -u git://android.git.kernel.org/platform/manifest.git 可以用 -m 参数来选择 repository 中的某一个特定的 manifest 文件,如果不具体指定,那么表示为默认的 namifest 文件 (default.xml)
repo init -u git://android.git.kernel.org/platform/manifest.git -m dalvik-plus.xml 可以用 -b 参数来指定某个manifest 分支。
repo init -u git://android.git.kernel.org/platform/manifest.git -b release-1.0
可以用命令: repo help init 来获取 repo init 的其他用法
4. repo sync [project-list]
5. repo update[ project-list ]
6. repo diff [ project-list ]
7. repo download
target revision
8. repo start newbranchname
9.
repo prune [project list]
10. repo foreach [ project-lists] -c command
11. repo status