What is the difference between "close" and "delete" a branch?


What's the difference between 'closing' and 'deleting' a branch?

I see these two terms bandied about but I'm not sure what they mean precisely in the context of Git. Are they both effectively referring to the same thing (git branch -d) or is there some subtle difference of which I should be aware?

I may be wrong but so far my understanding is that, unless I tag the branch prior to deletion, once the branch is deleted there's no evidence left behind that it ever existed. Correct?

There is no explicit command in git that is referred to as a close it is possible that by convention, some programmers refer to a branch as "closed" when it is merged back into the project and is no longer being maintained. Sometimes the branch is kept around, other times it is deleted, but the idea is that it is not being used anymore.

To answer your second question, there are a few ways you can keep track of a branch after you delete it. The most common way is via a remote host. Running git -d branch_name will only destroy your local copy. The remote host will still have its version in case you need it later. You can also stash the branch you are about to delete and come back to it later. This is how you stash

git stash save "I'm saving this branch before I delete it because yolo"

Here is a link on how to use stash to achieve your end, but your end it an unusual use case: https://www.kernel.org/pub/software/scm/git/docs/git-stash.html

Basically, if you stash your branch then you would have a record of its existence after deleting it. Additionally, if you merged that branch into other branches then those branches still know something about the existence of the deleted branch (mostly just that it existed). Again you can see what a given branch knows about its own merge history with git log --graph

There may be other ways that a branch can be seen in some fashion after deletion, but this should not be an issue for most workflows.