如何删除(或合并)我当前所在的本地Git分支? [英] How can I delete (or merge) a local Git branch that I'm currently on?

查看:59
本文介绍了如何删除(或合并)我当前所在的本地Git分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对使用git很陌生,我用它为AOKP Android ROM做出了贡献.我已经成功创建了几个分支,修改了代码,并上传了已在远程端合并的提交.但是在我的本地存储库中,那些分支仍在显示(即使它们显示为没有更改).问题是,当我创建这些分支时,我是从需要修改的子文件夹中执行此操作的,因此我没有任何更高"的分支可以去.因此,我无法删除这些分支-git tels me error:无法删除您当前所在的分支'MyMods'.

I'm pretty new to using git, and I use it to contribute to the AOKP Android ROM. I've successfully created a few branches, modified the code, and uploaded the commits that have gotten merged on the remote end. But in my local repository, those branches are still showing up (even though they show up as having no changes). The problem is that when I created those branches, I did so right from the subfolder that needed to be modified, so I don't have any "higher" branches to go to. And because of that, I can't delete those branches -- git tels me error: Cannot delete the branch 'MyMods' which you are currently on.

那我该怎么做才能摆脱那些分支?

So what can I do to get rid of those branches?

推荐答案

先删除一个分支,然后再删除它:

Checkout a different branch first, before deleting it:

git checkout master
git branch -d MyMods

此外,分支与文件夹无关.Git总是一次跟踪整个存储库及其所有文件夹和文件.分支不过是存储库历史记录中指向单个提交或快照的指针.

Also, branches have nothing to do with folders. Git always tracks the whole repository at once, with all its folders and files. A branch is nothing else than a pointer to a single commit, or snapshot, in the history of the repository.

这篇关于如何删除(或合并)我当前所在的本地Git分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆