Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
badges earned

Your Points Tracker
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to create master branch in remote repositories?

I encounter an issue when I create a bare repository. Here is my step:

1. Create a folder named `Test` in a `C:\` as a remote repository
2. Create repository in sourcetree and select `C:\Test`
3. Input command `git init --bare` in terminal
4. Clone `C:\Test` to my local folder `D:\Test`

However, I can't see master branch in both `C:\Test` and `D:\Test`. How can I create a master branch? Thanks

PS: my `C:\Test` has hooks, info, objects, refs, config, description, HEAD. Do I need to check in them and make them as master branch?

1 answer

1 accepted

0 votes
Answer accepted
Sandesh Shetty Community Leader Jun 04, 2020

A bare repository is pretty much something you only push to and fetch from. You cannot do much directly "init": you cannot check stuff out, create references (branches, tags), run git status, etc.

If you want to create a new branch in a bare Git repository, you can push a branch from a clone to your bare repo:

cd cloned-repo


git add .

git commit -m "added readme"

git push origin master 

Thanks for your answer. But I tried this before. and I got this error. Does my procedure of setting up repo right?

Total 3 (delta 0), reused 0 (delta 0)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: is denied, because it will make the index and work tree inconsistent
remote: with what you pushed, and will require 'git reset --hard' to match
remote: the work tree to HEAD.
remote: You can set the 'receive.denyCurrentBranch' configuration variable
remote: to 'ignore' or 'warn' in the remote repository to allow pushing into
remote: its current branch; however, this is not recommended unless you
remote: arranged to update its work tree to match what you pushed in some
remote: other way.
remote: To squelch this message and still keep the default behaviour, set
remote: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To C:\Test
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'C:\Test'

Sandesh Shetty Community Leader Jun 04, 2020

@W William Try this and then push

git config --bool core.bare true

Thanks mate! It works!

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Bitbucket

New improvements to user management in Bitbucket Cloud 👥

Hey Community! We’re willing to wager that quite a few of you not only use Bitbucket, but administer it too. Our team is excited to share that we’ll be releasing improvements throughout this month of...

266 views 2 10
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you