git - 从 git-branch 重新隐藏远程分支
问题描述
我克隆了一个远程仓库git clone
。回购有很多分支。在我的本地终端中,我键入git branch
显示master
. 如果我输入git branch -a
,我会看到本地和远程的所有分支。如果我使用 切换到远程分支git checkout remote-branch
并继续输入git branch
,我将同时看到master
和remote-branch
。我做我的工作remote-branch
,一些代码功能不起作用,我决定回去掌握,git checkout master
我不想删除这个remote-branch
。
假设我想重新隐藏remote-branch
. 这可能吗?git branch
master
解决方案
当您这样做时git checkout remote-branch
,git 首先尝试在本地查找该 ref。
由于您只有master
(并且假设您正在运行足够新的 git 版本),因此它会检查是否存在具有该名称的远程分支。如果是这样,它会创建一个同名的本地分支,并将上游设置为远程分支。
这就是为什么当你这样做时可以看到它列出的原因git branch
要“隐藏”它,您必须将其删除。(请记住,远程分支不受此影响。)
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>
推荐阅读
- laravel - 如何将excel数据导入laravel
- android - Firebase App Check 无法正常工作(解码 App Check 令牌失败)
- python - 如何在 PySpark 中进行数据分析?错误:DataFrame' 对象没有属性 'ix'
- reactjs - 如何将reactiveVar返回添加到数组?
- python - 在 Python 中重现 Excel 平均值和舍入
- eclipse - STM32CubeIDE 和多目标
- bash - 如何让 cron 作业在指定时间启动 VPN?
- google-sheets - 3个日期之间的平均天数?谷歌表格
- javascript - 数据不会从弹出窗口存储在 chrome.storage.local 中以进行 chrome 扩展
- react-native - react-native-render-html: "你好像在短时间内更新了 Y 组件的 X 属性..."