Skip to content

Instantly share code, notes, and snippets.

@barriosnahuel
Created July 31, 2018 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barriosnahuel/93e6a955cf64478ac886dc0d06aeb37a to your computer and use it in GitHub Desktop.
Save barriosnahuel/93e6a955cf64478ac886dc0d06aeb37a to your computer and use it in GitHub Desktop.
Useful git cloner when working with forks
#!/bin/bash
########
## USAGE
########
#
# > clone $yourForkGitUrl $directoryName
#
########
## SETUP
########
#
# Add an alias like the following one:
# > alias clone='sh ~/Downloads/cloner.sh'
REPOSITORY_GIT_URL=$1
DIRECTORY=$2
echo "Cloning... $REPOSITORY_GIT_URL" &&
git clone $REPOSITORY_GIT_URL $DIRECTORY &&
cd $DIRECTORY &&
REPOSITORY="${REPOSITORY_GIT_URL##*/}" &&
UPSTREAM="git@github.com:mercadolibre/$REPOSITORY" &&
echo "Adding remote: $UPSTREAM" &&
git remote add upstream $UPSTREAM &&
echo "Remote 'upstream' added ok." &&
git fetch upstream &&
git branch -m mine/develop &&
echo "Done! Please run: > cd $DIRECTORY"
@marcherdiego
Copy link

Me vuelvo locoooooo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment