简体   繁体   English

正确处理git分支?

[英]proper handling of git branching?

So far I've only used git for solo projects, but for last we days I've been working with a friend on a team project, but the branching kinda confuses me. 到目前为止,我只在个人项目中使用git,但是最近几天我们一直在和一个朋友一起进行团队项目,但是分支有点让我感到困惑。

When I was working on a new feature (based on an issue), I created the branch from within the issue. 当我研究新功能时(基于问题),我从问题内部创建了分支。 Then I fetched it using 然后我用

git fetch git获取

I started working on the branch by doing 我开始在分支机构工作

git checkout featurebranch git checkout功能分支

and doing my part of coding. 并完成我的编码工作。 After I was done, I commited the changes and pushed them to the branch 完成后,我提交更改并将其推送到分支

git commit -m ... git commit -m ...

git push git推

after that, I created a merge request on the gitlab page and approved the merge with an option to "remove the branch after merging" selected 之后,我在gitlab页面上创建了合并请求,并通过选择“合并后删除分支”的选项批准了合并

The branch got merged and deleted from the remote repository. 该分支已合并并从远程存储库中删除。 I checked out back to master, however when I do 我签出回到大师,但是当我这样做

git branch --list git branch --list

I can still see master & featurebranch. 我仍然可以看到母版和功能分支。 How do I delete the featurebranch from my local repo? 如何从本地存储库中删除功能分支? What's the proper way of handling branching, so no "leftovers" stay in the repo? 处理分支的正确方法是什么,这样回购中就不会剩下“剩余”?

"remove the branch after merging" function only removed branch in GitLab server's repository. “合并后删除分支”功能仅删除了GitLab服务器存储库中的分支。

But you have one default remote origin and one local branch. 但是您有一个默认的远程起源和一个本地分支。

  1. To remove branch on remote origin in your local repository, you should execute git fetch --prune to prune deleted branches on server. 要删除本地存储库中远程源上的分支,应执行git fetch --prune来修剪服务器上已删除的分支。
  2. To remove local branch which you checkout before, you should use git branch -d featurebranch to remove it. 要删除您之前检出的本地分支,应使用git branch -d featurebranch删除它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM