Developing
To work with the Android code, you will need to use both Git and Repo. In most situations, you can use Git instead of Repo, or mix Repo and Git commands to form complex commands. Using Repo for basic across-network operations will make your work much simpler, however.
Git is an open-source version-control system designed to handle very large projects that are distributed over multiple repositories. In the context of Android, we use Git for local operations such as local branching, commits, diffs, and edits. One of the challenges in setting up(建立) the Android project was figuring out(解决) how to best support the outside community--from the hobbiest community to large OEMs building mass-market consumer devices. We wanted components to be replaceable, and we wanted interesting components to be able to grow a life of their own outside of Android. We first chose a distributed revision control system, then further narrowed it down to Git.
Repo is a repository management tool that we built on top of Git. Repo unifies(统一) the many Git repositories when necessary, does the uploads to our revision control system, and automates parts of the Android development workflow. Repo is not meant to replace Git, only to make it easier to work with Git in the context of Android. The repo command is an executable Python script that you can put anywhere in your path. In working with the Android source files, you will use Repo for across-network operations. For example, with a single Repo command you can download files from multiple repositories into your local working directory.
Gerrit is a web-based code review system for projects that use git. Gerrit encourages more centralized use of Git by allowing all authorized users to submit changes, which are automatically merged if they pass code review. In addition, Gerrit makes reviewing easier by displaying changes side by side in-browser and enabling inline comments.
Basic Workflow
The basic pattern of interacting with the repositories is as follows:
Use
repo startto start a new topic branch.Edit the files.
Use
git addto stage changes.Use
git committo commit changes.Use
repo uploadto upload changes to the review server.
Task reference
The task list below shows a summary of how to do common Repo and Git tasks. For information about using repo to download source, see Downloading the Source and Using Repo.
Synchronizing your client
To synchronize the files for all available projects:
$ repo sync
To synchronize the files for selected projects:
$ repo sync PROJECT0 PROJECT1 PROJECT2 ...
Creating topic branches
Start a topic branch in your local work environment whenever you begin a change, for example when you begin work on a bug or new feature. A topic branch is not a copy of the original files; it is a pointer to a particular commit. This makes creating local branches and switching among them a light-weight operation. By using branches, you can isolate one aspect of your work from the others. For an interesting article about using topic branches, see Separating topic branches. 
To start a topic branch using Repo:
$ repo start BRANCH_NAME
To verify that your new branch was created:
$ repo status
Using topic branches
To assign the branch to a particular project:
$ repo start BRANCH_NAME PROJECT
To switch to another branch that you have created in your local work environment:
$ git checkout BRANCH_NAME
To see a list of existing branches:
$ git branch
or
$ repo branches
The name of the current branch will be preceded by an asterisk(星号).
Note: A bug might be causing repo sync to reset the local topic branch. If git branch shows * (no branch) after you run repo sync, then run git checkout again.
Staging files
By default, Git notices but does not track the changes you make in a project. In order to tell git to preserve your changes, you must mark them for inclusion in a commit. This is also called "staging".
You can stage your changes by running
git add
which accepts as arguments any files or directories within the project directory. Despite the name, git add does not simply add files to the git repository; it can also be used to stage file modifications and deletions.
Viewing client status
To list the state of your files:
$ repo status
To see uncommitted edits:
$ repo diff
The repo diff command shows every local edit that you have made that would not go into the commit, if you were to commit right now. To see every edit that would go into the commit if you were to commit right now, you need a Git command, git diff. Before running it, be sure you are in the project directory:
$ cd ~/WORKING_DIRECTORY/PROJECT
$ git diff --cached
Committing changes
A commit is the basic unit of revision control in git, consisting of a snapshot of directory structure and file contents for the entire project. Creating a commit in git is as simple as typing
git commit
You will be prompted for a commit message in your favorite editor; please provide a helpful message for any changes you submit to the AOSP. If you do not add a log message, the commit will be aborted.
Uploading changes to Gerrit
Before uploading, update to the latest revisions:
repo sync
Next run
repo upload
This will list the changes you have committed and prompt you to select which branches to upload to the review server. If there is only one branch, you will see a simple y/n prompt.
Recovering sync conflicts
If a repo sync shows sync conflicts:
- View the files that are unmerged (status code = U).
- Edit the conflict regions as necessary.
Change into the relevant project directory, run
git addandgit commitfor the files in question, and then "rebase" the changes. For example:$ git add .
$ git commit
$ git rebase --continueWhen the rebase is complete start the entire sync again:
$ repo sync PROJECT0 PROJECT1 ... PROJECTN
Cleaning up your client files
To update your local working directory after changes are merged in Gerrit:
$ repo sync
To safely remove stale topic branches:
$ repo prune
Deleting a client
Because all state information is stored in your client, you only need to delete the directory from your filesystem:
$ rm -rf WORKING_DIRECTORY
Deleting a client will permanently delete any changes you have not yet uploaded for review.
Git and Repo cheatsheet

Developing的更多相关文章
- Codeforces Round #222 (Div. 1) D. Developing Game 线段树有效区间合并
D. Developing Game Pavel is going to make a game of his dream. However, he knows that he can't mak ...
- [C# WPF]MoeEroViewer Developing Log
[C# WPF]MoeEroViewer Developing Log 1st - Base Document run on Https://github.com/Amarillys/MoeEroVi ...
- Google Developing for Android 三 - Performance最佳实践
Google Developing for Android 三 - Performance最佳实践 发表于 2015-06-07 | 分类于 Android最佳实践 原文 Developing ...
- Google Developing for Android 二 - Memory 最佳实践 // lightSky‘Blog
Google Developing for Android 二 - Memory 最佳实践 | 分类于 Android最佳实践 原文:Developing for Android, II Th ...
- Google Developing for Android 一 - 相关上下文介绍
前几天在G+上看到Google Developers站点,有一个Android系列的文章,分享到个人微博,周末闲来没事就学写了下,把它们简单的翻译了下,没想到一发不可收拾,六篇文章全部都翻译完了,有些 ...
- AX7: Get started developing
This blog will show how you can start making a customization in AX 7 by showing you the steps needed ...
- Spark(2) - Developing Application with Spark
Exploring the Spark shell Spark comes bundled with a PERL shell, which is a wrapper around the Scala ...
- Codeforces Round #322 (Div. 2) C. Developing Skills 优先队列
C. Developing Skills Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- Developing iOS8 Apps with Swift——iOS8概览
iOS 8 概览 斯坦福公开课--Developing iOS8 Apps with Swift学习笔记 想学习Swift,但是相应的教程不是很多,在CoCoaChina社区闲逛时恰好发现了这门课程, ...
- Developing your first FNC custom control
Friday, May 13, 2016 Some weeks ago, we released the TMS FNC UI Pack, a set of Framework Neutral Com ...
随机推荐
- ztr loves lucky numbers 傻逼的我来了个大模拟
http://acm.hdu.edu.cn/showproblem.php?pid=5676 这题的正解因该是dfs的,但是有18个位,然后我一算,全排列的话,有18!个啊,那不是很大?但是有很多是相 ...
- PHP使用Socket发送字节流
例如,需要发送以下数据 struct header { int type; // 消息类型 int length; // 消息长度 } struct MSG_Q2R2DB_PAYRESULT { ...
- jmeter压力测试中遇到的问题汇总
1.线程数大于1的时候,计数器配置没有勾选reset counter选项,导致测试结果出错 正常结果: 实际结果:index大于count数量时出错,病区及床号直接显示在count的基础上开始加1了 ...
- Asp.Net实现记录历史访问人数和当前在线人数
************************************在Global.asax中如下************************ <%@ Import Namespace= ...
- jsp get与post请求乱码问题
乱码问题01:<%reques.setCharacterEncoding("utf-8");%> 02:get请求乱码 001.:String 编码之后的字符串 = n ...
- 绘制复杂的原理图元件库用于cadence(二)
绘制Xilinx XC7K325TFFG900 kintex-7 FPGA元件 1.在官网搜索“pin out”往下拉一下就能看见 2.点击进入选择相应型号 3.打开之后是类似txt格式的FFG900 ...
- cf1028C. Rectangles(前缀和)
题意 给出$n$个矩形,找出一个点,使得至少在$n$个矩阵内 Sol 呵呵哒,昨天cf半夜场,一道全场切的题,我没做出来..不想找什么理由,不会做就是不会做.. 一个很显然的性质,如果存在一个点 / ...
- 用好js与nodejs中的try...catch
对异常的捕获和处理是提高程序鲁棒性的一个重要方式,即使在javascript/nodejs等看似“很难写出bug”的弱类型语言里,异常捕获处理仍至关重要,这主要是因为: 1.在一个代码块里,如果程序运 ...
- thinkphp分页集成
控制器: $User = M('webcase'); // 实例化 User 对象 $list = $User->order('id desc')->page($_GET['p'].', ...
- MD5 介绍
MD5(单向散列算法)的全称是Message-Digest Algorithm 5(信息-摘要算法),经MD2.MD3和MD4发展而来.MD5算法的使用不需要支付任何版权费用. MD5功能: 输入任意 ...