Skip to content

Instantly share code, notes, and snippets.

@alabeduarte
Last active November 28, 2016 17:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alabeduarte/3199c5f96d19c67ec3e3 to your computer and use it in GitHub Desktop.
Save alabeduarte/3199c5f96d19c67ec3e3 to your computer and use it in GitHub Desktop.
clone or pull git repo
#!/usr/bin/env bash
function clone_or_pull () {
root_dir=`pwd`
if [ -d $1 ]; then
echo "Prepare to pull the latest version of $1"
cd $1
git pull origin master
else
echo "Prepare to clone $1"
git clone git@github.com:$1.git
fi
pwd
echo "Going back to $root_dir"
cd $root_dir
}
# usage:
# clone_or_pull alabeduarte/feedparser-promised
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment