Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

bash

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?

like image 892
kikito Avatar asked Sep 01 '25 03:09

kikito


1 Answers

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.'
like image 91
jcollado Avatar answered Sep 02 '25 16:09

jcollado