1

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?

WILLIAM
  • 457
  • 5
  • 28
  • 1
    Commit something to the repo. After a `git ini` the repo is empty. – fredrik Jun 04 '20 at 10:34
  • @fredrik Thanks for your reply. But what should be the procedure? After git init --bare actually there are lots of files as I listed in "PS" – WILLIAM Jun 04 '20 at 10:37
  • 1
    You do that on you clone, not on the bare repo - it doesn't have a workspace for you to commit on. Go to your clone and use `git add`, `git commit` and you probably want `git push` as well. – fredrik Jun 04 '20 at 10:51
  • 1
    I would suggest walking through one of the many excellent git tutorials available online first, and then coming back here if you still have questions. – larsks Jun 04 '20 at 11:04

1 Answers1

1

As I explained in "Why do I need to explicitly push a new branch?", an initialized repository (bare or not) has 0 branch.

You need, in the non-bare repository D:\Test, to create, add and commit a file, in order for any branch (here the master branch by default) to be created.
You can see an example here.

Then: git push -u origin master will update the remote bare repository.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250