如何关闭Git分支?

时间:2011-12-23 09:13:06

标签: git github

所以我开始使用Git + GitHub。

在我们的小型分布式团队中,每个成员都为每个分配的问题/要求创建自己的分支。

  1. git branch Issue#1 <-- create this branch
  2. git checkout issue#1 <-- switch over to this branch
  3. 现在code codecommitcodecommit等...

    然后pull requestcode-fixupcommitcodecommit等等。

    和FINALLY ...接受拉取请求。

    活泉。

    但是......现在怎么样? (......尴尬......)

    在本地开发机器上创建分支的人是否需要关闭分支?建议开发人员删除分支`(... -D ...),然后对主设备进行拉/刷...然后将获得所有分支代码。

    嗯...不确定 - 请帮忙:)。

3 个答案:

答案 0 :(得分:168)

我们要求开发人员要求拉取请求声明他们希望删除分支。大部分时间都是这种情况。有时需要分支(例如,将更改复制到另一个发布分支)。

我的手指记住了我们的过程:

git checkout <feature-branch>
git pull
git checkout <release-branch>
git pull
git merge --no-ff <feature-branch>
git push
git tag -a branch-<feature-branch> -m "Merge <feature-branch> into <release-branch>"
git push --tags
git branch -d <feature-branch>
git push origin :<feature-branch>

分支是为了工作。标签标记了一个时间点。通过标记每个分支合并,如果需要,我们可以恢复分支。已经多次使用分支标签来查看更改。

答案 1 :(得分:39)

是的,只需运行git push origin :branchname即可删除分支。要在以后解决新问题,请再次从master分支。

答案 2 :(得分:37)

完成代码后,首先将分支合并到master,然后删除该分支

git checkout master
git merge <branch-name>
git branch -d <branch-name>