如何关闭一个分支,而不从git中的历史中删除它? [英] How to close a branch WITHOUT removing it from history in git?

查看:688
本文介绍了如何关闭一个分支,而不从git中的历史中删除它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想进行提交并关闭其分支,不会将其从历史记录中删除

code> commit --close-branch ,然后更新到上一个,然后继续工作。使用git ...我很困惑。

解决方案

没有确切的等同于在Git中关闭分支,因为Git分支是比Mercurial更轻量。他们的水银相当于书签而不是分支。

如果我理解正确,在Mercurial中关闭一个分支大致会使它从分支列表中消失,因此您可以通过归档来实现同样的目的。 通常的做法是将其提示标记为存档,并将其删除:

  git tag archive /< branchname> < BRANCHNAME> 
git branch -d< branchname>
git checkout master

分支将被删除,稍后可以通过检出标签,并重新创建分支:

  git checkout archive /< branchname> 
git checkout -b new_branch_name


I'd like to make a commit and close its branch, without removing it from history.

With mercurial I'd commit --close-branch, then update to a previous one, and go on working. With git... I'm confused.

解决方案

There's no exact equivalent to closing a branch in Git, because Git branches are more lightweight than in Mercurial. Their Mercurial equivalent is more bookmarks than branches.

If I understand correctly, closing a branch in Mercurial roughly makes it disappear from the branch list, so you can achieve the same thing by archiving it. A usual practice is to tag its tip as archive, and delete it:

git tag archive/<branchname> <branchname>
git branch -d <branchname>
git checkout master

The branch will be deleted, and can be retrieved later by checking out the tag, and recreating the branch:

git checkout archive/<branchname>
git checkout -b new_branch_name

这篇关于如何关闭一个分支,而不从git中的历史中删除它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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