Adding and removing remote branches
Frequently we have to work parallelly to master branch on an exciting feature of your product, right? More often then this is sharing it so your co-workers can contribute and make it even more exciting.
Adding remote branches
The problem is that every time that you create a new branch it’s created locally and you can’t just push your changes because git doesn’t know where to push it. Git stores your branch’s configuration on your .git/config file like this:
[branch "ftw_feature"] remote = merge =
You can solve this problem manually, every goddamn time setting branch’s remote configurations in .git/config file or if you’re working with git’s version 1.7+ you can use the –set-upstream flag instead.
git branch --set-upstream ftw_feature origin/ftw_feature
Now, just like magic your .git/config file should look like this:
[branch "ftw_feature"] remote = origin merge = refs/heads/ftw_feature
Or if your you’re sadly running under 1.7 git’s version you can still do a better approach than manually (or not too verbose for me):
git config branch.ftw_feature.remote origin git config branch.ftw_feature.merge refs/heads/ftw_feature
Removing remote branches
If somehow you screw things up and have to clean the mess before anyone notices, just type:
git push origin :ftw_feature
Or even more intuitive:
git push origin --delete ftw_feature
That does the job.