从git分支重新隐藏远程分支
我使用从git分支重新隐藏远程分支,git,branch,Git,Branch,我使用git clone克隆远程repo。回购协议有许多分支机构。在本地终端中,我键入git branch,其中显示master。如果我键入git branch-a,我会看到本地和远程的所有分支。如果我使用git checkout remote branch切换到远程分支,然后继续键入git branch,我将同时看到master和remote branch。我在remote branch上工作,有些代码功能不起作用,我决定用git checkout master返回master,我不想删除这个
git clone
克隆远程repo。回购协议有许多分支机构。在本地终端中,我键入git branch
,其中显示master
。如果我键入git branch-a,我会看到本地和远程的所有分支。如果我使用git checkout remote branch
切换到远程分支,然后继续键入git branch
,我将同时看到master
和remote branch
。我在remote branch
上工作,有些代码功能不起作用,我决定用git checkout master
返回master,我不想删除这个remote branch
假设我想从
git branch
重新隐藏远程分支
,就像我在回到master
之后克隆repo的开始一样。这可能吗?当您执行git签出远程分支时,git首先尝试在本地分支中查找该引用
由于您只有master
(并且假设您运行的是最新的git版本),因此它会检查是否有具有该名称的远程分支。如果是这样,它将创建一个同名的本地分支,并将上游设置为远程分支
这就是为什么在执行git分支时可以看到它被列出的原因
要“隐藏”它,您必须删除它。(请记住,远程分支不会因此受到任何影响。)
git签出主机
吉特分行-d
#如果分支未合并,上述操作将失败并显示一条消息
#(具有未合并到“主控”中的提交)
#如果您确实希望删除,请坚持
吉特分行-D
git checkout master
git branch -d <branchName>
# the above will fail with a message if the branch is unmerged
# (has commits which aren't merged into `master`)
# if you do want the deletion to occur nonetheless, insist with
git branch -D <branchName>