Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens behind the scenes when I do a repo sync?

What happens behind the scenes when I do a repo sync in my Android repository?

Is it equivalent to repo forall -c "git pull" or maybe git fetch? Or does it do something more complex?

Thanks

like image 764
Bjarke Freund-Hansen Avatar asked Feb 23 '11 07:02

Bjarke Freund-Hansen


People also ask

How do I continue syncing my repository?

If you want to pause the repo sync for a while and resume it later time of the day, press "CTRL + Z" and to resume the sync, type "fg" and press enter.

What is sync command in git?

git-sync is a simple command that pulls a git repository into a local directory. It is a perfect "sidecar" container in Kubernetes - it can periodically pull files down from a repository so that an application can consume them. git-sync can pull one time, or on a regular interval.

What is repo command in Linux?

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.


1 Answers

There's a description on this page of what repo sync does. In the usual case it will be more like git pull --rebase than git pull. To quote what that page says:

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.

Essentially the git remote update makes sure that your remote-tracking branches (including origin/branch) are up-to-date by running git fetch origin. (In fact, the behaviour of git remote update is more complex than that, and depends on your git config, but in a typical setup it'll run git fetch [remotename] for each of your remotes.) Then the git rebase origin/branch rewrites your branch by replaying all your commits that aren't present upstream onto origin/branch.

like image 171
Mark Longair Avatar answered Oct 16 '22 08:10

Mark Longair