Skip to content

Instantly share code, notes, and snippets.

@andymotta
Last active August 17, 2018 18:29
Show Gist options
  • Save andymotta/fc9fa41aff249e90468e0acb3b2ad575 to your computer and use it in GitHub Desktop.
Save andymotta/fc9fa41aff249e90468e0acb3b2ad575 to your computer and use it in GitHub Desktop.
Clone or pull git repo in Shell script
#!/bin/bash
function clone_pull {
DIRECTORY=$(basename "$1" .git)
if [ -d "$DIRECTORY" ]; then
cd "$DIRECTORY"
git pull
cd ../
else
git clone "$1"
fi
}
clone_pull https://github.com/andymotta/s3-fsnotify-go
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment