repo和git基本命令


Android 使用 Git 作为代码管理工具,我们有必要学习一下repo 和 git 相关的基本命令:

1.初始化 repo 库,该命令可以在后面添加 --depth=1,表示只下载最近版本的代码,只保留最近的commit版本,可以节省本地磁盘空间

repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest
repo init -u https://aosp.tuna.tsinghua.edu.cn/platform/manifest --depth=1

2.同步代码,-c 只下载当前分支代码 ,提升下载速度,节省空间

repo sync -c

3.回滚所有git分支代码

repo forall -c git reset --hard HEAD
repo forall -c git clean -fd

4.在源代码根目录执行命令:

repo start --all branch_name

5.删除指定本地分支:

repo abandon branch_name

6.单个分支代码提交:

git add -A
git commit
git push origin HEAD:refs/for/branch_name

7.代码未merge时,可以通过下面命令修改提交文件,提交说明

git commit --amend

8.创建本地分支,切换本地分支

git checkout -b local_branch_name origin/branch_name
git checkout local_branch_name

9.代码提交冲突时:

git remote update
git rebase origin/branch_name    //rebase远程分支
git status                       //查看冲突地方并修改
git add -f .
git rebase --continue
git commit --amend
git push

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM