Created
July 31, 2018 20:31
-
-
Save barriosnahuel/93e6a955cf64478ac886dc0d06aeb37a to your computer and use it in GitHub Desktop.
Useful git cloner when working with forks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Me vuelvo locoooooo