Last active
June 12, 2017 14:40
-
-
Save josemigallas/91f53653620c1142c20306187a42128d to your computer and use it in GitHub Desktop.
Script that clones a repository and adds both remotes origin and upstream, renaming origin with a definde username.
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 | |
# Definitions | |
GITHUB_USER=josemigallas | |
# Verify arguments | |
if [ -z "$1" ] || [ -z "$2"]; then | |
echo "Missing forked and upstream repos' urls. | |
Usage: git-clone <origin> <upstream>" | |
exit 0 | |
fi | |
# Script arguments | |
URL_ORIGIN=$1 | |
URL_UPSTREAM=$2 | |
# Get repo's name | |
BASE_NAME=$(basename $URL_ORIGIN) | |
REPO_NAME=${basename%.*} | |
# Get username | |
# ?? | |
# Clone the repo and add upstream | |
git clone $URL_ORIGIN $REPO_NAME | |
( | |
cd $REPO_NAME | |
git remote rename origin $GITHUB_USER | |
git remote add upstream $URL_UPSTREAM | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment