Skip to content

Instantly share code, notes, and snippets.

@dlip
Created June 4, 2020 00:59
Show Gist options
  • Save dlip/683f881924f7ff448b6c6f4c65360632 to your computer and use it in GitHub Desktop.
Save dlip/683f881924f7ff448b6c6f4c65360632 to your computer and use it in GitHub Desktop.
Git checkout latest on a different branch without moving your HEAD twice
# Git checkout latest on a different branch without moving your HEAD twice
gcol() {
if [ -z $1 ]; then
echo "Error: Please provide branch name"
return
fi
git fetch
git branch -f $1 origin/$1
git checkout $1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment