Creating topic branches (also called "feature branches") is easy in Git and
is one of the best things about Git. Sometimes we also want to get those pushed
from our local repo for various reasons:
- To make sure it's safe on another server (for backup).
- To let others review it.
- To let others build upon it.
Here we'll just be dealing with #1 and #2, and not talking about how to collaborate
on a shared branch. We'll be assuming that only the original author will push to it,
and that nobody else will be doing work based on that branch.
- Creating a feature branch (using name/name_issue)
git checkout -b rfay/some_feature_39949494/05
git checkout -b rfay/some_feature_39949494
- Pushing it up (with origin xxx)
git push origin rfay/some_feature_39949494
- Turning a regular branch into a tracking branch (if you like shorter commands)
git config --global push.default tracking # One time setup.
git branch --set-upstream foo upstream/foo
- OR just create a new tracking branch and forget all that.
git branch -m [my_current_branch] junk
git checkout --track origin/[branch]
- OR if you have commit access to the upstream branch
git push -u upstream foo
git push -u origin foo
- When you need to, delete the branch
git branch -d [branch] # If it's been merged
git branch -D [branch] # unconditionally
git push origin :[branch] # pretty odd syntax