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?
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:
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'.
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'C:\Test'
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...
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