kikito
kikito

Reputation: 52651

git clone - how do I supress the "You appear to have cloned an empty repository" warning?

I've got an automated script that parses a server and clones all the repos in one of its folders. The pseudocode of what it does is:

for each repo_name
  if a folder named like repo_name exists in .
    cd repo_name
    git fetch origin
  else
    git clone repo_url
  end
end

These repos are, in occasions, empty repositories. Then the git clone command fails - or the script I use thinks it fails. It prints a message on stderror (I think) saying

You appear to have cloned an empty repository

Well, thank you, git, but that was no error.

I tried adding the --quiet option to the command, but that message keeps appearing.

Is there a way to supress it, without supressing the rest of possible errors?

Upvotes: 4

Views: 1619

Answers (1)

jcollado
jcollado

Reputation: 40384

Not very elegant, but how about redirecting stderr to stdout and filtering that error with grep?

git clone repo_url 2>&1 | grep -v 'warning: You appear to have cloned an empty repository.'

Upvotes: 3

Related Questions