Kin*_*nch 20
通常,您不直接在裸存储库中创建分支,但是您将分支从一个工作存储库推送到裸存储库
git push origin myBranch
Run Code Online (Sandbox Code Playgroud)
更新:值得一提
就像Paul Pladijs在评论中提到的那样
git push origin localBranchName:remoteBranchName
Run Code Online (Sandbox Code Playgroud)
您将本地分支推送(并创建,如果不存在)到具有不同分支名称的本地分支,即本地分支.并使其完整
git push origin :remoteBranchName
Run Code Online (Sandbox Code Playgroud)
你删除了一个远程分支.
git update-ref refs/heads/new_branch refs/heads/master
Run Code Online (Sandbox Code Playgroud)
在那个裸存储库中,如果您可以直接访问它.您可以在最后一个参数中提供任何引用(例如标记)或提交.
以下是测试脚本:
$ mkdir non-bare-orig
$ cd non-bare-orig/
$ git init
Initialized empty Git repository in D:/Temp/bare-branch/non-bare-orig/.git/
$ touch file1
$ git add --all && git commit -m"Initial commit"
[master (root-commit) 9c33a5a] Initial commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file1
$ touch file2
$ git add --all && git commit -m"Second commit"
[master 1f5673a] Second commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file2
$ git tag some_tag
$ touch file3
$ git add --all && git commit -m"Third commit"
[master 5bed6e7] Third commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file3
$ cd ../
$ git clone --bare non-bare-orig bare-clone
Cloning into bare repository 'bare-clone'...
done.
$ cd bare-clone/
$ git update-ref refs/heads/branch1 refs/heads/master
$ git update-ref refs/heads/branch2 some_tag
$ git update-ref refs/heads/branch3 9c33a5a
$ git branch -vv
branch1 5bed6e7 Third commit
branch2 1f5673a Second commit
branch3 9c33a5a Initial commit
* master 5bed6e7 Third commit
Run Code Online (Sandbox Code Playgroud)
创建一个名为branchname的新分支(本地)
git branch branchname
Run Code Online (Sandbox Code Playgroud)
然后将它与远程存储库同步,如github(如果适用)
git push origin branchname
Run Code Online (Sandbox Code Playgroud)
并将其用于开发/使分支成为活动分支
git checkout branchname
Run Code Online (Sandbox Code Playgroud)