Lets Play Nebulous
Lets Play Nebulous

Reputation: 51

If I delete a branch without merging, what happens? Can I do that to undo my changes?

Imagine you just created a new branch, added some commits and noticed you messed up. Can you now just delete the (not merged) branch to undo your changes?

Talking about the regular Github page.

Thanks!

Upvotes: 0

Views: 1080

Answers (2)

johnfo
johnfo

Reputation: 1842

If you are using branches, then you should be aware of the branching pattern you are using:) Most people use some sort of trunk branch (master/main/develop) and feature or story branches. Whether you use PRs to merge or just merge and push locally is probably irrelevant here.

On that basis, code on a branch makes no difference to the trunk itself and whether you choose to delete the branch or just leave it on github and allow to wither is of little difference - there are pros to leaving the code there. Whatever, if somebody else has cloned the repo, they will have a copy and might have started to use it - thus the distributed nature of git.

There are two potential places I can think of where there may be issues:

  1. The branch contains something it should not - such as somebody else's copyright code. In that situation, you definitely want to delete it ASAP.
  2. You accidentally push a big file to the repo. This will not cause logical problems but will usually slow down cloning. Again best to delete the branch.

Upvotes: 0

TheIceBear
TheIceBear

Reputation: 3255

It is gone from origin, meaning the main version of your repo, meaning the version that is on GitHub.com. However, someone might have had time to clone the repo and checked out that branch in their clone. Then that branch exist in the clone regardless what you do to origin if that is important. Including your own clone.

(Technically something else can be origin but I am assuming here that you do not have some advanced set up. What I assume would be the case if you have created your repo on GitHub.com and not changed any advanced settings.)

Upvotes: 0

Related Questions