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