If I create a new branch, make a few commits, and then decide, "wow, I've done nothing good here," and I delete the branch (git branch -d branchname
) do those few commits go away too? As in, do they disappear from my git log?
The commits won't show up in git log
anymore when no branch references them, but they will be kept around for a while to prevent accidental loss of work. There are several safety layers:
git gc
will keep your reflog entries there and will not delete commits still reachable via those reflog entries.git gc
will still keep objects if they were created less than two weeks ago (by default; this is configurable).git gc
.To look at reflogs, try git log -g SOMEBRANCH
.
Yes, they disappear from the git log, and no, they do not disappear from the repository until the subsequent git gc
(garbage collector) command.
You can still find those commits using the git reflog
command.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With