using git and repo

本文介绍了在Android开发中使用Git和Repo进行版本控制和项目管理的方法,包括安装、配置、同步、创建和使用主题分支、查看状态、解决冲突、清理文件以及上传更改等操作。
Contents


   1. 1 About Git
         1. 1.1 Why Git?
         2. 1.2 Already a Git user?
   2. 2 Task reference
         1. 2.1 Installing Repo
         2. 2.2 Synchronizing your client
         3. 2.3 Why use topic branches?
         4. 2.4 Creating topic branches
         5. 2.5 Using topic branches
         6. 2.6 Viewing client status
         7. 2.7 Recovering sync conflicts
         8. 2.8 Cleaning up your client files
         9. 2.9 Deleting a client
        10. 2.10 Scripting common tasks
   3. 3 Repo command reference
         1. 3.1 init
         2. 3.2 sync
         3. 3.3 upload
         4. 3.4 diff
         5. 3.5 download
         6. 3.6 forall
         7. 3.7 help
         8. 3.8 prune
         9. 3.9 start
        10. 3.10 status
   4. 4 Git and Repo cheatsheet
   5. 5 Terminology


To work with the Android code, you will need to use both Git and Repo.


    * 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.


    * Repo is a tool that we built on top of Git. Repo helps us manage the many Git repositories, 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.


About Git
Why Git?
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.
Already a Git user?
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. For more information about Git, see the list of resources on our Documentation page. 
Task reference
The task list below shows a summary of how to do common Repo and Git tasks. For complete quick-start information and examples, see Get source.
Installing Repo
$ curl http://android.git.kernel.org/repo >~/bin/repo
$ chmod a+x ~/bin/repo
$ mkdir working-directory-name
$ cd working-directory-name
$ repo init -u git://android.git.kernel.org/platform/manifest.git


Synchronizing your client
To synchronize the files for all available projects:
$ repo sync


To synchronize the files for selected projects:
$ repo sync project1 project2 ...


Why use 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.




Creating topic branches
To start a topic branch using Repo:
$ repo start branchname


To verify that your new branch was created:
$ repo status


Using topic branches
To assign the branch to a particular project:
$ repo start branchname project


To switch back and forth among branches that you have created in your local work environment:
$ git checkout branchname


To see a list of existing branches:
$ git branch


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.


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 down in the project directory:
$ cd ~/workingdirectory/project
$ git diff --cached


Recovering sync conflicts
If a repo sync shows sync conflicts:


   1. View the files that are unmerged (status code = U).
   2. Edit the conflict regions as necessary.
   3. Change into the relevant project directory, run git add and git commit for the files in question, and then "rebase" the changes. For example:
      $ cd bionic
      $ git add bionic/*
      $ git commit
      $ git rebase --continue


   4. When the rebase is complete start the entire sync again:
      $ repo sync bionic proj2 proj3 ... projN


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
Deleting a client will permanently delete any changes you have not yet uploaded for review. Because all state information is stored in your client, you only need to delete the directory from your filesystem:


    $ cd ~
    $ rm -rf working-directory-name


Scripting common tasks
You can use Repo to run the same program across all projects:


    $ repo forall [ proj1 proj2 ... projN ] -c 'echo $REPO_PROJECT $@' [ arg1 arg2 ... argN ]


The -c argument is evaluated through /bin/sh and any arguments after it are passed through as shell positional parameters.


Repo command reference
Repo usage takes the following form:
   repo command options


Optional elements are shown in brackets [ ]. Once Repo is installed, you can get information about any command by running
   repo help command


init
repo init -u url [ options ]


Installs Repo in the current directory. This creates a .repo/ directory that contains Git repositories for the Repo source code and the standard Android manifest files. The .repo/ directory also contains manifest.xml, which is a symlink to the selected manifest in the .repo/manifests/ directory.


The -u argument specifies a URL from which to retrieve a manifest repository. For example:
  $ repo init -u git://android.git.kernel.org/platform/manifest.git


To select a manifest file within the repository, use the -m option. (If no manifest name is selected, the default is default.xml.) For example:
  $ repo init -u git://android.git.kernel.org/platform/manifest.git -m dalkvik-plus.xml


To specify a revision, that is, a particular manifest-branch, use the -b option. For example:
  $ repo init -u git://android.git.kernel.org/platform/manifest.git -b release-1.0


To see other repo init options, run
  $ repo help init


Note: For all remaining Repo commands, the current working directory must either be the parent directory of .repo/ or a subdirectory of the parent directory.


sync
repo sync [ project-list ]


Downloads new changes and updates the working files in your local environment. After a successful repo sync, the code in specified projects will be up to date with the code in the remote repository.


You can specify project-list as a list of names or a list of paths to local source directories for the projects:
   repo sync [proj1 proj2 ... projN]


If you run repo sync without any arguments, it will synchronize the files for all the projects.


How Repo synchronization works
When you run repo sync, this is what happens:


   1. If the project has never been synchronized, then repo sync is equivalent to git clone. All branches in the remote repository are copied to the local project directory.
   2. If the project has already been synchronized once, then repo sync is equivalent to:
        git remote update
        git rebase origin/branch
      where branch is the currently checked-out branch in the local project directory. If the local branch is not tracking a branch in the remote repository, then no synchronization will occur for the project.


      If the git rebase operation results in merge conflicts, you will need to use the normal Git commands (for example, git rebase --continue) to resolve the conflicts.


The repo sync command also updates the private repositories in the .repo/ directory.


upload
repo upload [ project-list ]


For the specified projects, Repo compares the local branches to the remote branches updated during the last repo sync. Repo will prompt you to select one or more of the branches that have not yet been uploaded for review.


After you select one or more branches, all commits on the selected branches are transmitted to Gerrit over an SSH connection.  You will need to configure an SSH key to enable upload authorization.  Visit SSH Keys within the user settings panel to register your public keys with Gerrit.  To enable password-less uploads, consider using ssh-agent on your client system.


When Gerrit receives the object data over its SSH server, it will turn each commit into a change so that reviewers can comment on each commit individually.


To combine several "checkpoint" commits together into a single commit, use git rebase -i before you run repo upload.


You can specify project-list as a list of names or a list of paths to local source directories for the projects:
   repo upload [proj1 proj2 ... projN]


If you run repo upload without any arguments, it will search all the projects for changes to upload.


To make edits to changes after they have been uploaded, you should use a tool like git rebase -i or git commit --amend to update your local commits.


After your edits are complete:


   1. Make sure the updated branch is the currently checked out branch.
   2. Use repo upload --replace proj1 to open the change matching editor.
   3. For each commit in the series, enter the Gerrit change Id inside the brackets:


 # Replacing from branch foo
 [ 3021 ] 35f2596c Refactor part of GetUploadableBranches to lookup one specific...
 [ 2829 ] ec18b4ba Update proto client to support patch set replacments
 [ 3022 ] c99883fe Teach 'repo upload --replace' how to add replacement patch se...
 # Insert change numbers in the brackets to add a new patch set.
 # To create a new change record, leave the brackets empty.


After the upload is complete the changes will have an additional Patch Set (e.g. Patch Set 2, Patch Set 3, ...).


diff
repo diff [ project-list ]


Shows changes between commit and working tree.


You can specify project-list as a list of names or a list of paths to local source directories for the projects:
   repo diff [proj1 proj2 ... projN]


Options:
  -h, --help  means show this help message and exit.


download
repo download target change


Downloads the specified change into the specified local directory. (Added to Repo as of version 1.0.4.)


For example, to download change 1241 into your platform/frameworks/base directory:
   $ repo download platform/frameworks/base 1241


A "repo sync" should effectively remove any commits retrieved via "repo download".  Or, you can check out the remote branch; e.g., "git checkout m/master".


Note: As of Jan. 26, 2009, there is a mirroring lag of approximately 5 minutes between when a change is visible on the web in Gerrit and when repo download will be able to find it, because changes are actually downloaded off the git://android.git.kernel.org/ mirror farm. There will always be a slight mirroring lag as Gerrit pushes newly uploaded changes out to the mirror farm.


forall
repo forall [ project-list ] -c command [ arg...]


Runs a shell command in each project.


You can specify project-list as a list of names or a list of paths to local source directories for the projects


help
repo help [ command ]


Displays detailed help about a command.


prune
repo prune [ project-list ]


Prunes (deletes) topics that are already merged.


You can specify project-list as a list of names or a list of paths to local source directories for the projects:
   repo prune [proj1 proj2 ... projN]


start
repo start newbranchname [ project-list ]


Starts a new branch for development.


The newbranchname argument should provide a short description of the change you are trying to make to the projects.  If you don't know, consider using the name default.


The project-list specifies which projects will participate in this topic branch. You can specify project-list as a list of names or a list of paths to local working directories for the projects:
   repo start default [proj1 proj2 ... projN]


"." is a useful shorthand for the project in the current working directory.


status
repo status [ project-list ]


Shows the status of the current working directory. You can specify project-list as a list of names or a list of paths to local source directories for the projects:
   repo status [proj1 proj2 ... projN]


To see the status for only the current branch, run
   repo status .


The status information will be listed by project. For each file in the project, a two-letter code is used:


    * In the left-most column, an uppercase letter indicates what is happening in the index (the staged files) when compared to the last committed state.


    * In the next column, a lowercase letter indicates what is happening in the working directory when compared to the index (what is staged).


 Character     Meaning
 A    The file is added (brand new). Can only appear in the first column.
 M or m
    The file already exists but has been modified in some way.
 D or d
    The file has been deleted.
 R    The file has been renamed. Can only appear in the first column. The new name is also shown on the line.   
 C    The file has been copied from another file. Can only appear in the first column. The source is also shown.
 T    Only the file's mode (executable or not) has been changed. Can only appear in the first column.
 U    The file has merge conflicts and is still unmerged. Can only appear in the first column.
 -    The file state is unmodified. A hyphen in both columns means this is a new file, unknown to Git. After you run git add on this file, repo status will show A-, indicating the file has been added.


For example, if you edit the file main.py within the appeng project without staging the changes, then repo status might show


   project appeng/
    -m     main.py


If you go on to stage the changes to main.py by running git add, then repo status might show


   project appeng/
    M-     main.py


If you then make further edits to the already-staged main.py and make edits to another file within the project, app.yaml, then repo status might show


   project appeng/
    -m     app.yaml
    Mm     main.py


Git and Repo cheatsheet
Click on the cheatsheet to open it in a new window for easier printing.


Terminology
Staged changes
Changes marked by git add for inclusion in the next commit's snapshot.


Commit
At intervals, you use git commit to save a snapshot of the staged files and a log message that describes the change.


Manifest
A manifest file that contains a list of repositories and a mapping of where the files from these repositories will be located within your working directory. When you synchronize your files, the files contained in the repositories that are listed in the manifest will be pulled into your working directory.
内容概要:本文档详细介绍了基于直驱永磁同步发电机(PMSG)的1.5MW风力发电系统在Simulink环境下的建模与仿真全过程,涵盖了风力机空气动力学模型、PMSG电磁特性建模、不可控整流与逆变电路、直流环节、空间矢量脉宽调制(SVPWM)技术以及核心控制策略的设计。重点实现了最大功率点跟踪(MPPT)控制以提升风能捕获效率,并构建了电压外环与电流内环协同工作的双闭环控制系统,通过仿真验证了系统在不同风速条件下稳定运行的能力及动态响应性能。; 适合人群:适用于具备电力系统、电机控制理论基础及Simulink仿真操作经验的研究生、科研人员和从事新能源发电系统开发的工程技术人员;特别适合正在进行风电系统建模、控制算法研究或完成相关毕业设计的专业人士。; 使用场景及目标:①深入理解直驱式PMSG风力发电系统的整体架构与工作机理;②掌握从物理部件建模到控制策略实现的完整Simulink仿真流程;③学习并复现MPPT控制、双闭环控制等关键技术方案;④为后续开展低电压穿越、并网稳定性分析、故障诊断等高级课题提供可靠的仿真平台支撑。; 阅读建议:建议结合Matlab/Simulink软件动手实践,逐模块搭建模型,重点关注各控制环节的参数设计与调试方法,同时可参照文中提供的其他风电相关资源进行拓展学习与对比分析。
已经博主授权,源码转载自 https://pan.quark.cn/s/868afdd63918 在信息技术领域中,前端开发构成了Web应用程序构建的关键环节,而登录注册页面则是用户与网站进行互动的起始界面。"150款web登录注册页面模板(附带效果图+源码)"这一资源为前端工程师们提供了一系列预先设计的界面组件,支持他们迅速构建既美观又实用的登录及注册界面,从而有效缩减开发周期并增强工作效率。 这些模板囊括了多样化的风格和设计潮流,涵盖了扁平化设计、Material Design、渐变色彩、暗黑模式等,能够适应不同项目的特定要求。在设计中强调用户体验,通过科学的布局安排,提升了表单的便捷操作性和可辨识度,并且不忽视视觉层面的吸引力。设计师通常会关注自适应设计,保证页面在多种设备(涵盖手机、平板及桌面电脑)上均能呈现良好的视觉效果。 这些模板均配备了源代码,使得开发者得以深入探究并个性化定制每个构成部分,涉及HTML的页面构造、CSS的样式修饰以及JavaScript的交互逻辑。HTML主要承担着页面基础结构的搭建,CSS用于实现页面美化与布局控制,JavaScript则常用于处理表单验证和交互效果。对于那些精通这三种技术的开发者而言,他们可以根据个人需求对模板进行功能扩展和样式调整。 在实际部署时,登录注册页面通常需要集成基础的输入项,例如用户名、密码、电子邮箱等,并且必须重视安全性考量,诸如密码强度指引、验证码系统等。除此之外,为了优化用户体验,还可能集成记住密码、自动填充、社交平台登录(例如微信、QQ、微博)等功能。 在开发阶段,前端工程师还需关注Web标准和无障碍访问(WCAG)规范,确保页面的通用友好性,这包括视障、听障或其他有特殊需求的用户群体。具体措施涉及标...
源码直接下载地址: https://pan.quark.cn/s/9af8b9f95652 ### Multisim模型的导入和使用 ### 一、引言 随着电子设计自动化(EDA)工具的进步,Multisim已经成为电子工程师进行电路仿真、分析和设计的关键工具之一。借助Multisim,工程师们能够便捷地构建电路模型,并对电路进行仿真验证。本文将系统阐述如何在Multisim中导入并运用芯片仿真模型,这对于提升电子产品的研发效能具有显著价值。 ### 二、Multisim中构建新元器件 构建新元器件是Multisim中的核心功能,特别是对于那些需要特定模型或无法从Multisim库中直接获取的元器件来说更为关键。以下为构建新元器件的具体流程: ##### 步骤1:录入元器件信息 在Multisim中启动“Component Wizard”,即元器件向导,开始创建新的元器件。首先需要录入元器件的基本资料,包括型号、主要功能、类型等。这些资料将有助于用户更高效地管理和检索元器件。 ##### 步骤2:录入封装信息 接下来需要设定元器件的封装信息。在这一环节中,用户需要依据实际芯片的封装规格来选择适宜的引脚数量。同时,还需明确是构建单一部件元器件还是复合部件元器件。如果是复合部件元器件,则必须确保引脚数量与符号中使用的引脚数量保持一致。 ##### 步骤3:录入符号信息 在此步骤中,用户可以编辑元器件在仿真过程中的显示符号。编辑符号可以通过三种途径进行:直接编辑、从数据库中复制现有符号或复制当前符号以备将来使用。编辑符号时应注重其在电路图中的可辨识度和清晰度。 ##### 步骤4:设定管脚参数 在该步骤中,用户需要参照数据手册上的管脚顺序为每个管脚命名,并选择恰当的类型。...
代码转载自:https://pan.quark.cn/s/7b1a6710052c Vivado 2018.2 与 ModelSim 的协同仿真操作 Vivado 2018.2 是由 Xilinx 公司开发的一款用于 FPGA 设计的工具,它包含了丰富的设计和仿真功能。然而,在实际应用过程中,用户可能会遇到其自带的仿真工具运行效率不高的问题。为了提升仿真效率并简化设计验证流程,可以考虑采用第三方仿真工具 ModelSim。ModelSim 是一款性能卓越且市场应用广泛的仿真软件,接下来的内容将详细阐述如何实现 Vivado 2018.2 与 ModelSim 的联合使用。 配置 ModelSim 的安装路径 在使用 Vivado 2018.2 时,首先需要配置 ModelSim 的安装位置。用户可以通过点击 Vivado 菜单中的“Tools”——>“Settings...”选项,然后在弹出的设置界面中,选择“Tool Settings”下的“3rd Party Simulators”选项卡。在“Install Paths”区域,找到“ModelSim”条目,并在此输入或选择 ModelSim 的具体安装路径。 执行器件库编译操作 在 ModelSim 的安装目录下,创建一个名为 xilinx_lib 的子文件夹。随后,在 Vivado 菜单中通过“Tools”——>“Compile Simulation Libraries...”选项启动器件库编译流程,并设定相应的编译参数。在打开的对话框里,将仿真工具选择为“ModelSim Simulator”,保持语言和库的默认设置不变,同时指定编译器件库的存放位置和 ModelSim 可执行文件的路径。 ...
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值