I want to be able to do the following:
Create a local branch based on some other (remote or local) branch (via git branch
or git checkout
I suppose that you have already cloned a project like:
git clone http://github.com/myproject.git
Then in your local copy, create a new branch and check it out:
git checkout -b <newbranch>
Supposing that you made a "git bare --init" on your server and created the myapp.git, you should:
git remote add origin ssh://example.com/var/git/myapp.git
git push origin master
After that, users should be able to
git clone http://example.com/var/git/myapp.git
NOTE: I'm assuming that you have your server up and running. If it isn't, it won't work. A good how-to is here.
Add a remote branch:
git push origin master:new_feature_name
Check if everything is good (fetch origin and list remote branches):
git fetch origin
git branch -r
Create a local branch and track the remote branch:
git checkout -tb new_feature_name origin/new_feature_name
Update everything:
git pull
For GitLab version prior to 1.7, use:
git checkout -b name_branch
(name_branch, ex: master
)
To push it to the remote repository, do:
git push -u origin name_new_branch
(name_new_branch, example: feature
)
If you are not sharing your repo with others, this is useful to push all your branches to the remote, and --set-upstream
tracking correctly for you:
git push --all -u
(Not exactly what the OP was asking for, but this one-liner is pretty popular)
If you are sharing your repo with others this isn't really good form as you will clog up the repo with all your dodgy experimental branches.