问题描述
我想进行提交并关闭其分支,不会将其从历史记录中删除。
code> commit --close-branch ,然后更新
到上一个,然后继续工作。使用git ...我很困惑。
如果我理解正确,在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中的历史中删除它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!