pmmarq
10/30/2017 - 8:03 PM

Change origin url git

git remote set-url origin git@<new-git-url>

git remote add internal <new-git-url>

# Delete local branch
git branch -D the_local_branch

# Check out branch from a non-origin upstream
# git fetch <upstream/fork name
# https://stackoverflow.com/questions/30862558/checkout-branch-on-different-remote
git fetch dbergin
git checkout -b <branchname> --track dbergin/<branchname>

# How do I know which remote/branch I'm tracking?
# https://stackoverflow.com/questions/171550/find-out-which-remote-branch-a-local-branch-is-tracking
git for-each-ref --format='%(upstream:short)' $(git symbolic-ref -q HEAD) origin/mainline
git rev-parse --abbrev-ref --symbolic-full-name @{u}

# or if you want an alias
alias getTrackingBranch="git rev-parse --abbrev-ref --symbolic-full-name @{u}"