How do I create a master branch in a bare Git repository?

后端 未结 4 847
夕颜
夕颜 2020-12-13 00:13

(All done in poshgit on Windows 8):

git init --bare test-repo.git
cd test-repo.git

(Folder is created with git-ish files and folders inside

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-13 00:26

    A branch is just a reference to a commit. Until you commit anything to the repository, you don't have any branches. You can see this in a non-bare repository as well.

    $ mkdir repo
    $ cd repo
    $ git init
    Initialized empty Git repository in /home/me/repo/.git/
    $ git branch
    $ touch foo
    $ git add foo
    $ git commit -m "new file"
    1 file changed, 0 insertions(+), 0 deletions(-)
    create mode 100644 foo
    $ git branch
    * master
    

提交回复
热议问题