S
S
Sazoks2021-03-22 11:07:33
git
Sazoks, 2021-03-22 11:07:33

What if I deleted a branch without deleting the commit?

There was a branch that needed to be deleted. There were several big commits.
I, unknowingly, deleted this branch, but the size of the repository in bytes did not decrease, then I realized that I had failed.
Now we need to delete this data somehow.
Well, if someone did not understand, this happened because I deleted the branch, but not the commit itself, fixing the data.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Romses Panagiotis, 2021-03-22
@romesses

First, deleting branches, tags, and commits does not reduce the size of the repository, because git only works on adding.
Secondly, if the changes are already synced to the remote git repository, then you just have to live with it.
And only if the changes are local and not executed git push, then the branch can be rolled back to the desired commit.
Let's say the origin/development branch is located on a remote git repository, and 2 commits were added locally with unnecessary changes (dll binaries, for example). Thus, the development branch is ahead of origin/development by 2 commits. Then we execute:
git reset --hard origin/development
Added :
There is also a destructive bfg utility to remove data from the git history:
https://rtyley.github.io/bfg-repo-cleaner/
https://www.phase2technology.com/blog/removing-lar...
If the changes are only local, then you can work with this utility locally and then nothing unnecessary will get to the remote git repository.
And if you have already hit, then there is an even more dangerous thing: try to recreate the repository locally and re-upload it.

V
vaut, 2021-03-22
@vaut

You need to force garbage collection:
$ git gc --auto
Unreachable objects will be removed.
Read more:
https://git-scm.com/book/en/v2/Git-%D0%B8%D0%B7%D0...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question