repo syncCommand to synchronize the Android code of the remote server. If the code is modified locally but there is no commit, you will be prompted that you cannot Sync:
error: android/frameworks/base/: contains uncommitted changes
At this point, you can use the
git resetThe command discards the local modification before executing it
repo syncTo synchronize the code.
If you want to force synchronization of remote server code without losing local modifications, you can add
repo sync -dThe command will force the head to the repo manifest version, ignoring local changes.
Check the help information of repo help sync. The description of – D option is as follows:
detach projects back to manifest revision
be careful: plus
-dThe option only means that local changes are ignored and the code of the remote server can be forcibly synchronized. However, the locally modified files will remain unchanged and the local changes will not be forcibly overridden. Moreover, after synchronization, the local branch direction will change and no longer point to the original branch. Specific examples are as follows.
1. The following is the implementation
repo sync -dPrevious branch information:
$ git branch * curent_branch_xxx
2. The following is the implementation
repo sync -dNext branch information:
$ git branch * (detached from 715faf5) curent_branch_xxx
That is to say, the code synchronized from the remote server is the branch that tracks the remote server. The code has not been checked out from the GIT warehouse to the local. However, the current local modified code is in the unnamed branch, which is a different branch and does not interfere with each other. Only in this way can the remote server code be forced to synchronize without discarding the local modification.
git statusCommand, you can see that there are still modified files that have not been committed locally. After synchronizing the remote server code, you will not forcibly override the modification of local files
$ git status HEAD detached at 715faf5 Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git checkout -- <file>..." to discard changes in working directory) modified: vendor/chioverride/default/g_pipelines.h modified: vendor/topology/g_usecase.xml
That is, if you want to discard the local modification and make the local code consistent with the synchronized git repository code,
repo sync -dOrders don’t do that.
In addition, repo Sync has a
--force-syncOptions are as follows:
overwrite an existing git directory if it needs to point to a different object directory. WARNING: this may cause loss of data
From the description, it seems that synchronization can be forced and local changes may be lost. However, the actual test found that this option does not force local changes to be overridden. If the local file is changed, plus this option, an error will be reported in sync:
$ repo sync --force-sync . Fetching project tools/ error: tools/: contains uncommitted changes
--force-syncThe local modification cannot be forced to be overridden.
Not found at this time
repo syncCommand to force the override of locally modified options.