git fetch <origin> <remote_branch>
git checkout -b <local_branch_name> <origin>/<remote_branch>
git checkout <remote_branch>
git checkout -b <local_branch> # if no local created yet
git branch -u <origin>/<remote_branch>
I don't remember where I found this but it's quite useful.
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="your-old-email@example.com"
CORRECT_NAME="Your Correct Name"
CORRECT_EMAIL="your-correct-email@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_COMMITTER_NAME="$CORRECT_NAME"
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
fi
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
then
export GIT_AUTHOR_NAME="$CORRECT_NAME"
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
fi
' --tag-name-filter cat -- --branches --tags
Steps to add a remote repo to a local project and sync with it.
I always forget these steps so noting them here. This does assume that an empty repo is first created on GitHub.