Reputation: 30128
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
Upvotes: 13
Views: 10871
Reputation: 467591
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
.
Upvotes: 17