Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does repo init and repo sync actually do?

I posted this question at Android Enthusiasts but figured it was the wrong place to ask, so I deleted it from there and asking it "again" here.


This is such a noob question, and pardon me if it is, but I just want to understand the underlying concepts clearly. Reading repo help and Google's repo command reference page doesn't really enlighten much. I understood some bits from Google's reference page, but I still need some more clarifications.

Following the instructions on how to download android source, I executed these two commands on an Ubuntu shell: (I've taken cared of all the prerequisites for the environment.)

~/android4.2.2$ repo init -u https://android.googlesource.com/platform/manifest -b android-4.2.2_r1.2 ~/android4.2.2$ repo sync -j4 

After waiting half a day for repo to finish downloading, I ended up with 19G of downloaded material in android4.2.2 directory. So what exactly just happened, and why did it reach 19G when Google said I should only be expecting around 8G of source files?

like image 716
Poly Bug Avatar asked Jul 30 '14 20:07

Poly Bug


People also ask

What does GH repo sync do?

Sync destination repository from source repository. Syncing uses the main branch of the source repository to update the matching branch on the destination repository so they are equal.

What is repo sync in Linux?

reposync is used to synchronize a remote yum repository to a local directory, using yum to retrieve the packages.

Does repo sync overwrite local changes?

repo sync does not overwrite local changes, so I don't think you're doing what you think you're doing. Can you give us a more detailed example of how you're using the command?

What is the difference between git clone and repo init?

git init vs.git clone is used to create a copy of an existing repository. Internally, git clone first calls git init to create a new repository. It then copies the data from the existing repository, and checks out a new set of working files. Learn more on the git clone page.


1 Answers

repo is a python wrapper script for git, its Google Source page defines it as

repo - The Multiple Git Repository Tool

  1. repo init command initializes repo in the current directory. That's, it downloads the latest repo source and a manifest.xml file that describes the directory structure of the git repositories, and store all of these in .repo sub-directory in the current directory. In your case, you have used an optional -b argument which is used to select the branch to checkout. By default (i.e., when -b argument is not used), master branch is used.

  2. repo sync updates working tree to the latest revision. That's, it synchronizes local project directories with the remote repositories specified in the manifest file. If a local project does not yet exist, it will clone a new local directory from the remote repository and set up tracking branches as specified in the manifest. If the local project already exists, it will update the remote branches and rebase any new local changes on top of the new remote changes. -j argument is used to set number of parallel jobs to execute. The default value can be defined in the manifest, and also can be overridden in command line as in your case.

why did it reach 19G when Google said I should only be expecting around 8G of source files?

That should be because besides the source files, you will get all the history of Android since the beginning of the time :)

Hope this helps.

like image 184
ozbek Avatar answered Oct 11 '22 12:10

ozbek