renaming master branch in git

I have master branch as default branch in github repository. I need two more branches called, ics and froyo, and I want to rename my master branch to ics.

first create two new branches

git branch froyo 
git branch ics 

now rename the =master= branch to =ics=

git branch -M -a master froyo

-M will rename the branch even if the new branch name already exists.

also I want to remove =master= branch from remote.

git push origin :master

Now if I want to set the default branch as ics on github, then login to github. Visit the repository, go to the Admin tab. In the Settings column, Change the Default branch from master to ics.


  1. to clone specific branch from git repository
    git clone -b BRANCH_NAME

    for example,

    git clone -b my-branch
  2. copy file from another branch

    for example,

    git co froyo
  3. to checkout particular branch from remotes
    git co -b BRANCH remotes/origin/BRANCH

    for example,

    git co -b froyo remotes/origin/froyo
  4. to remove files from git which are already deleted from system
    for file in $(git ls-files --deleted); do git rm $file; done