Git Tips

Creating a remote branch

First we need to create the remote branch:

git push origin origin:refs/heads/new_feature_name

Make sure everything is up-to-date

git fetch origin

Then you can see that the branch is created.

git branch -r

This should show ‘origin/new_feature_name’

Start tracking the new branch

git checkout --track -b new_feature_name origin/new_feature_name

This means that when you do pulls that it will get the latest from that branch as well.

Make sure everything is up-to-date

git pull

Creating a new empty local branch


  • Because you may want to start working on a different module for a project from scratch.
  • Because you may want to start a ptoject from scratch without loosing the current work kept in a different branch.


First we need to create the branch in our local repository:

git symbolic-ref HEAD refs/heads/new_name_branch

If we had any previous unsaved changes we may want to remove them:

git rm --cached -r .

We can now safely remove the old folders and files:

rm -rf *

Finally we make an initial commit (It will be empty):

git commit --allow-empty -m "your own message"

If we want to send the changes to the remote repository, we need to make sure we specify the remote name and the branch name:

git push origin new_name_branch

Also, be sure to include the branch config in your .git/config:

[branch "empty-branch-name"]
        remote = origin
        merge = refs/heads/empty-branch-name

External links

* []

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License