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
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.
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.
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.
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:
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.
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With