Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从git分支重新隐藏远程分支_Git_Branch - Fatal编程技术网

从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>