Repo和Git 版本管理常用命令总结

本文总结了Repo和Git在版本管理中的常见操作,包括从服务器下载和同步版本,上传本地修改,设置全局变量,查看修改记录,管理分支,以及Android代码编译流程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1. 服务器版本下载:

1、repo init -u ssh://xxx/platform/manifest.git -b branch-name

2、repo sync

3、repo start branch-name --all

或者:

git clone ssh://xxx.git

git checkout -b branch-name

 

2. 服务器新加仓库同步:

1:~> cd your_repo_path

2: git pull --rebase

 

3. 上传本地修改到服务器

repo forall -c git add .

repo forall -c git reset --hard

repo forall -c git pull --rebase        和服务器同步(要上传代码前,一般先进行此操作)

git add .  或 git add 文件名            添加当前仓库修改的文件

git commit -m "..."                          在引号中添加你的修改记录

git push                                        上传本地修改的代码

 

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="2013-01-01" --until="2013-09-24"   按条件查看工程所有仓库修改记录

repo status                查看工程中所有仓库的修改状态(包括文件位置)

git status                   查看仓库修改状态

 

6. 分支相关

git branch                 查看本地branch

git branch -r              查看远程branch

git branch -a              查看所有branch

git branch -D  (-d)  (branch name)    删除branch


7、代码编译

source ./build/envsetup.sh
lunch xxx-eng
mmm packages/apps/Gallery2/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值