|
| 1 | +--- |
| 2 | +title: Repo Tool |
| 3 | +category: git |
| 4 | +--- |
| 5 | + |
| 6 | +When getting into more complicated software development, you will usually end |
| 7 | +up having code split in mulitple repos. Groot, Merch and the GPU Cluster |
| 8 | +are all examples of moduluar projects with multiple repos. |
| 9 | + |
| 10 | +There are a couple ways to manage all the repos you use. Git submodules are one |
| 11 | +and they are really good for vendoring code that you don't actively develop in |
| 12 | +parallel with the code you are working on. It works by checking out a specific |
| 13 | +commit from another repo. |
| 14 | + |
| 15 | +Another tool more suited to parallel development is ```repo```. It is a tool |
| 16 | +created by Google for use on Android, to manage the various repos the project has. |
| 17 | + |
| 18 | +Many ACM projects also use ```repo`` to manage their sub repos. |
| 19 | + |
| 20 | +## Installing ```Repo``` |
| 21 | + |
| 22 | +Installing repo is easy, many OSes have it included in their package manager |
| 23 | + |
| 24 | +```sh |
| 25 | +brew install repo |
| 26 | +``` |
| 27 | + |
| 28 | +```sh |
| 29 | +apt install repo |
| 30 | +``` |
| 31 | + |
| 32 | +## Managing Repos |
| 33 | + |
| 34 | +Managing repos is done through a manifest in the format of an xml file. |
| 35 | +Within the xml file, the root git server is listed and the subdirectories |
| 36 | +of the repos are listed with their final arrangement on the client. |
| 37 | + |
| 38 | +```xml |
| 39 | +<?xml version="1.0" encoding="UTF-8"?> |
| 40 | +<manifest> |
| 41 | + <!-- Location of the git server (notice the protocol definition) --> |
| 42 | + <remote name="origin" fetch="ssh://git@github.com/acm-uiuc/" /> |
| 43 | + |
| 44 | + <!-- Default name for remote and branch --> |
| 45 | + <default remote="origin" revision="master" /> |
| 46 | + |
| 47 | + <!-- Path to place each repo on client and the name of the subdirectory on the git server for each repo --> |
| 48 | + <project path="." name="merch" /> |
| 49 | + <project path="merch-embedded" name="merch-embedded" /> |
| 50 | + <project path="merch-hardware" name="merch-hardware" /> |
| 51 | + <project path="merch-ios" name="merch-ios" /> |
| 52 | + |
| 53 | +</manifest> |
| 54 | + |
| 55 | +``` |
| 56 | + |
| 57 | +Call this file ```default.xml``` and place it at the root of your main repo |
| 58 | + |
| 59 | +> Note: It is recommended to use ssh with repo since you then don't need to use a password for every ``clone/push/pull``` |
| 60 | +
|
| 61 | +## Getting All Your Code |
| 62 | + |
| 63 | +To begin with, ```repo``` needs a directory to work in. So create one |
| 64 | + |
| 65 | +```sh |
| 66 | +mkdir merch |
| 67 | +``` |
| 68 | + |
| 69 | +Then you must initialize ```repo``` in that directory |
| 70 | + |
| 71 | +```sh |
| 72 | +repo init -u git@github.com:acm-uiuc/merch |
| 73 | +``` |
| 74 | + |
| 75 | +Finally pull the latest changes |
| 76 | + |
| 77 | +```sh |
| 78 | +repo sync |
| 79 | +``` |
| 80 | + |
| 81 | +You should now have all your code placed in the right places to start working |
| 82 | + |
| 83 | +To commit code back up use the standard ```git``` workflow |
| 84 | + |
| 85 | +## Cool Abilities |
| 86 | + |
| 87 | +Repo also allows you to do some powerful things |
| 88 | + |
| 89 | +For instance |
| 90 | + |
| 91 | +```sh |
| 92 | +repo forall |
| 93 | + |
| 94 | +``` |
| 95 | +Runs a command in every repo, good for pushing up a bunch of changes. |
| 96 | + |
| 97 | +For the full reference checkout https://source.android.com/source/using-repo |
0 commit comments