8

I'm building a script that will download several versions of Android. Rather than pulling each repository from scratch, I'd like to keep a base repository that I can re-init to the right version before syncing (and then copying the result to a safe directory).

However, repo init always prompts for a name and email address, foiling my scripting attempts. I've looked through the repo source and tried options like -q, but it seems like the prompting is coming from the underlying git commands.

Any suggestions on doing a repo init -b without interaction?

3 Answers 3

11

Tested solution: If you set user.name and user.email in the global git config, repo will not prompt for your name/email. You can set them by running the following git commands:

$ git config --global user.name 'Warren Turkal'
$ git config --global user.email '[email protected]'

Untested possible solution: I think you can also set those attributes in the manifest repo instead of changing your global config if you only want the name and email to be set for the one repo repository. To do that, you can do something like the following from the repo root:

$ cd .repo/manifests
$ git config user.name 'Warren Turkal'
$ git config user.email '[email protected]'
2
  • And make sure that you do not add the --config-name parameter to repo init, as it will then still ask you to confirm the user name and email
    – NexD.
    Aug 17, 2018 at 13:21
  • voting up for the second suggestion Jul 14, 2020 at 17:38
0

Why not just use git on it's own? That is way more scriptable. Pipe git archive to tar to export or git --work-tree=where/you/want/the/files checkout tag_name .

2
  • But as I understand it, I can't just feed in something like "android-1.6_r1" as the tag name in the git command you've provided, and get the equivalent of "repo init -b android-1.6_r1; repo sync". Correct me if I'm wrong, but if I use git, I have to handle each project for each version I'm interested in separately, right?
    – bhoward
    Nov 15, 2011 at 23:00
  • yes and no. If you handle it as one repo and don't bother exporting to another place, you don't need to handle each separately. Nov 15, 2011 at 23:26
-1

One way to force git-repo to be non-interactive is to attach something to its stdin:

repo init < /dev/null
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.