admin管理员组文章数量:1122846
I created a remote branch lets say "branch_a
" off of origin/main
. Then to keep the branch upto date, I did:
git fetch origin
git merge origin/main
I hope that's one of the right ways? I mean git rebase would also do. But git merge origin/main
is also legal I assume?
Basically its "Merge remote-tracking origin/main into branch_a" is what I see in gitlab after I do those commands. Yes I use gitlab.
Now question is it is safe to delete this remote branch branch_a
without affecting anything right?
Please suggest best practice if I did something incorrect.
I created a remote branch lets say "branch_a
" off of origin/main
. Then to keep the branch upto date, I did:
git fetch origin
git merge origin/main
I hope that's one of the right ways? I mean git rebase would also do. But git merge origin/main
is also legal I assume?
Basically its "Merge remote-tracking origin/main into branch_a" is what I see in gitlab after I do those commands. Yes I use gitlab.
Now question is it is safe to delete this remote branch branch_a
without affecting anything right?
Please suggest best practice if I did something incorrect.
Share Improve this question asked Nov 21, 2024 at 18:06 SomeDudeSomeDude 14.2k5 gold badges24 silver badges48 bronze badges 5 |2 Answers
Reset to default 1Now question is it is safe to delete this remote branch branch_a without affecting anything right?
Well it depends on multiple factors and what does without affecting anything mean.
Users who ran git fetch
while the branch existed will have it listed
in git branch -r
forever until they run git fetch --prune
. It only
takes space and might be confusing but will not break anything.
Users who created a local branch from it and let Git set up remote
branch automatically with git checkout <BRANCH>
will not be able to
pull from it any more.
Any PRs that were open against this branch should be immediately closed, at least that's what Bibucket and GitHub are doing.
Pushing a new branch may trigger CI systems build, depending on how it's configured and how many times it pulls the repository it may crash at some point because the commit on the tip of the branch was gone.
These won't be serious issues in most cases, especially if you didn't ask anyone to check out the branch (still, some users may do that on their own). And if you have it locally and someone else might need it again you can re-push it or restore it from reflog within the next 30 days.
Yes, it is safe to delete a remote branch (branch_a) after merging the main branch into it. You merged main into branch_a meaning that branch_a is now updated with all changes from main. If you have any new changes that are important in the branch_a make sure you make a pull request to the main before deleting the branch_a locally or remotely.
本文标签: gitlabDeleting remote branch after git merge originmainStack Overflow
版权声明:本文标题:gitlab - Deleting remote branch after git merge originmain? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736308182a1933569.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
Basically its "Merge remote-tracking origin/main into branch_a" is what I see in gitlab after I do those commands
- you also didgit push
, didn't you? – Arkadiusz Drabczyk Commented Nov 21, 2024 at 18:27git merge origin/main
while you were onbranch_a
? – Arkadiusz Drabczyk Commented Nov 21, 2024 at 19:39