git fetch origin
git checkout -b branchName origin/branchName
git checkout -b <branchName>
Create a branch of the same name as the remote branch.- You will be on the local branch with the same name as the remote branch
git branch --set-upstream-to=origin/<branchName> <branchName>
. This will set your local branch to track the remote branch of the same name.git pull
to pull down the branch information.git push origin <branchName>
to push up changes.
If the remote branch is behind on the master, instead of running git merge master
to get all the changes from the master branch, which creates a useless commit for the merging, use git rebase master
. This will fast forward the current branch to match the head of the master branch.
If you want to hide the current changes without committing them, run git stash
. To get back the changes, run git stash apply
.
You can also stash the changes, switch branch then apply those changes to the new branch.