3

How can I check if git has successfully cloned a repository, and based on that result, execute commands inside the bash script?

I was trying some combinations of grep checking the output of git status but I've only managed to confuse myself more.

I'm ruining timeout 60s git clone ... so I must make sure the repository has cloned fully, and if it has not to skip whatever it would have done with the cloned data.

BMW
  • 42,880
  • 12
  • 99
  • 116
dominique120
  • 1,170
  • 4
  • 18
  • 31
  • possible duplicate of [Capture output from git command?](http://stackoverflow.com/questions/13715261/capture-output-from-git-command) – BMW Mar 21 '14 at 05:40

2 Answers2

3

Have a look at it.

I think You are expecting this code.

https://stackoverflow.com/a/13715406/2959196

Also Have a look at the conversation. It might help you better.

How to detect if a git clone failed in a bash script

Community
  • 1
  • 1
ArunRaj
  • 1,780
  • 2
  • 26
  • 48
0

Your timeout command will return a non zero exit code if it terminates the program. Use that rather than checking the repository to see if it's cloned.

Noufal Ibrahim
  • 71,383
  • 13
  • 135
  • 169