I create a local branch in git for every Feature, Fix, ... I make. After I am done I create a Merge/Pull Request on the Github/Gitlab website and another developer reviews the code. Can I securely delete the local branch after creating the MR or is there any reason to keep it? Or should I maybe wait until the MR is accepted?
Asked
Active
Viewed 719 times
0
-
1Note that all a branch *name* does is remember a particular commit *hash ID* so that you can find the commit. Deleting the name has no effect on the commit; it just means you may no longer be able to *find* the commit. Eventually, commits that you can't find will leave your repository entirely, but may still exist in other repositories (such as those where the pull request is still sitting and being ignored). If *every* repository that has that commit loses *every* name that *finds* that commit, all repositories may eventually delete the commit, and *then* it's really gone. – torek Nov 10 '20 at 00:34
1 Answers
0
It's generally better to keep the branch as long as the pull request has not been approved and merged. The reason is that if somebody refuses your pull request or asks you for changes on your pull request, you can directly apply the changes and updates on the local branch without having to re-download it from the remote repository.

Sopsop
- 327
- 2
- 10
-
So best is to wait until the MR was accepted, but generally I cannot do something wrong, when I delete the branch instantly? – link Nov 09 '20 at 19:09
-
@link well I guess there is no problem if you decide to delete the local branch instantly because you will be able to download it from the remote at any moment. – Sopsop Nov 09 '20 at 19:46