N-M25
N-M25

Reputation: 49

git pull form bash returns fatal : Not a git repository (or any of the parent directories)

In bash, how can I say, clone the repository if directory doesn't exist and git pull if repository exist?

I have this , but it gives me fatal : Not a git repository (or any of the parent directories): .git

Here is my script:

#!/bin/sh
DIR=~/test/repo1
if [ -d $DIR]; then
    git pull
else
    cd ~/test
    git clone [email protected]/repo
fi

Upvotes: 0

Views: 407

Answers (1)

wgitscht
wgitscht

Reputation: 2776

if it exists (i.e. -d $DIR]; is true) you have to perform a changedir before you pull like so: cd $DIR. I don't really get the git clone, shouldn't it be something with repo1 in it?

Upvotes: 2

Related Questions