diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2024-06-19 09:07:28 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2024-06-19 09:07:28 -0300 |
commit | 3106b52eeb9cb8ded2497bf6611355b1f1bf4c87 (patch) | |
tree | ff2c641953b65f98630a826daf3e926cd0965d8e | |
parent | 9ca078dfc86af9c50446bceb818af7b48ce7a73e (diff) | |
download | utils-git-3106b52eeb9cb8ded2497bf6611355b1f1bf4c87.tar.gz utils-git-3106b52eeb9cb8ded2497bf6611355b1f1bf4c87.tar.bz2 |
Feat: adds git-clone-or-pull
-rwxr-xr-x | git-clone-or-pull | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/git-clone-or-pull b/git-clone-or-pull new file mode 100755 index 0000000..f2575c2 --- /dev/null +++ b/git-clone-or-pull @@ -0,0 +1,34 @@ +#!/usr/bin/env bash +# +# Handy single command to clone or pull a repository +# + +# Parameters +BASENAME="`basename $0`" +ORIGIN="$1" +DEST="$2" + +# Check +if [ -z "$DEST" ]; then + echo "usage: $BASENAME <origin> <dest>" + exit 1 +fi + +# Dispatch +if [ ! -e "$DEST" ]; then + echo "Cloning $ORIGIN into $DEST..." + git clone $ORIGIN $DEST +else + echo "Updating $DEST..." + git -C $DEST pull + + # Alternate approach, that restore any existing changes + #( + # cd $DEST &> /dev/null + # git restore . + # git pull + #) +fi + +# Exit +exit $? |