Skip to content

Instantly share code, notes, and snippets.

@ad1992
Created June 6, 2018 16:07
Show Gist options
  • Save ad1992/22b9d8b379f16a6c65524bd4cfd5c4ca to your computer and use it in GitHub Desktop.
Save ad1992/22b9d8b379f16a6c65524bd4cfd5c4ca to your computer and use it in GitHub Desktop.
Fetch a branch from someone's fork on github
echo "moving to current directory"
cd $PWD
echo -n "Enter name of the user whose forked branch you want to checkout"
read username
echo -n "Enter the name of the repository"
read repo
echo -n "Enter the name of the branch of the user"
read branch
git remote add $username git@github.com:$username/$repo.git
echo "Added remote repository"
git fetch $username
echo "fetching the user"
# will create a branch username-branchn in your local
git checkout -b $username-$branch $username/$branch
echo "$username-$branch branch created successfully"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment