Search code examples
gitgithubrepo

How to repo init a local .git and local manifest.xml


In traditional method, I will use this command to repo init and repo sync, and it works.

repo init -u https://github.com/abc/def.git -b main -m manifest.xml

But due to some reasons, I need to do something like this:

Step 1: clone the repo to my computer

git clone https://github.com/abc/def.git

Step 2: repo init from a local .git and local manifest.xml (Fail)

repo init -m manifest.xml

Fail at step 2 with this message "fatal: manifest url (-u) is required."

It was inside the git clone directory.

Anyone know how to repo init from a local git repo and local manifest.xml file ? Please provide code example if possible, Thanks.


Solution

  • You have several options.

    If there is already a repo workspace, which means repo init has been run and .repo exists, you could copy the manifest to .repo/manifests. Suppose it's .repo/manifests/manifest.xml, or rename it as .repo/manifests/my_manifest.xml in order to avoid naming conflicts. And then run

    repo sync -m my_manifest.xml
    

    or

    repo init -u https://github.com/abc/def.git -b main -m my_manifest.xml
    # my_manifest.xml does not have to be tracked as
    # long as it's under .repo/manifests
    repo sync
    

    If your own manifest.xml is tracked in a local repository /path/to/manifests/, on the branch foo, you could also use

    repo init -u file:///path/to/manifests -b foo -m manifest.xml
    repo sync
    

    file:// can be omitted.

    BTW, the remote element in the manifest file could also be a local repository.