Deleting branch does not remove its commits from repository #6894

Closed
opened 2025-11-02 07:10:20 -06:00 by GiteaMirror · 6 comments
Owner

Originally created by @pboguslawski on GitHub (Feb 18, 2021).

Hi,

In gitea v1.13 (build from 82637c240a) removing branch does not remove its content from gitea repo i.e. after removing from gitea repo branch test with commited 10MB file...

git clone https://my.domain/test/test.git
cd test
git checkout -b test master
dd if=/dev/urandom bs=1M count=10 of=./test10m.bin
git add test10m.bin 
git commit -m '10m file added'
git push origin test          
git log
# commit 4dafdb1968611ae188d828b429b3a8b9990114b1 (HEAD -> test, origin/test)
# [...]
git checkout master
git branch -D test
git push origin :test
# remote: . Processing 1 references
# remote: Processed 1 references in total
# To https://my.domain/test/test.git
# - [deleted]         test

...and after running manually

Clean-up deleted branches
Garbage collect all repositories

cron jobs from gitea admin UI I can still download test10m.bin file using

4dafdb1968/test10m.bin

Test branch is absent in this gitea repo - only its commits are still alive. Bug? How to purge such old data from gitea repo?

Regards,
Paweł

Originally created by @pboguslawski on GitHub (Feb 18, 2021). Hi, In gitea v1.13 (build from 82637c240aa3b0e0bf290d35b2014953edec5b6e) removing branch does not remove its content from gitea repo i.e. after removing from gitea repo branch `test` with commited 10MB file... ``` git clone https://my.domain/test/test.git cd test git checkout -b test master dd if=/dev/urandom bs=1M count=10 of=./test10m.bin git add test10m.bin git commit -m '10m file added' git push origin test git log # commit 4dafdb1968611ae188d828b429b3a8b9990114b1 (HEAD -> test, origin/test) # [...] git checkout master git branch -D test git push origin :test # remote: . Processing 1 references # remote: Processed 1 references in total # To https://my.domain/test/test.git # - [deleted] test ``` ...and after running manually ``` Clean-up deleted branches Garbage collect all repositories ``` cron jobs from gitea admin UI I can still download test10m.bin file using https://my.domain/test/test/raw/commit/4dafdb1968611ae188d828b429b3a8b9990114b1/test10m.bin Test branch is absent in this gitea repo - only its commits are still alive. Bug? How to purge such old data from gitea repo? Regards, Paweł
GiteaMirror added the type/question label 2025-11-02 07:10:20 -06:00
Author
Owner

@pboguslawski commented on GitHub (Feb 18, 2021):

Gitea in above example was using git version 2.30.0 from Debian bullseye.

@pboguslawski commented on GitHub (Feb 18, 2021): Gitea in above example was using git version 2.30.0 from Debian bullseye.
Author
Owner

@a1012112796 commented on GitHub (Feb 18, 2021):

It's not a bug. delete git branch will't delete any commits. to clean not needed commits, you need run git gc in server repo with some special options(can search it in Google).

@a1012112796 commented on GitHub (Feb 18, 2021): It's not a bug. delete git branch will't delete any commits. to clean not needed commits, you need run ``git gc`` in server repo with some special options(can search it in Google).
Author
Owner

@pboguslawski commented on GitHub (Feb 18, 2021):

you need run git gc in server repo

So whats the purpose of cron jobs

Clean-up deleted branches
Garbage collect all repositories

Shouldn't gitea do it automatically in one of above jobs? Forcing admin to run cli for such tasks seems not practical solution.

@pboguslawski commented on GitHub (Feb 18, 2021): > you need run git gc in server repo So whats the purpose of cron jobs ``` Clean-up deleted branches Garbage collect all repositories ``` Shouldn't gitea do it automatically in one of above jobs? Forcing admin to run cli for such tasks seems not practical solution.
Author
Owner

@a1012112796 commented on GitHub (Feb 18, 2021):

you need run git gc in server repo

So whats the purpose of cron jobs

Clean-up deleted branches
Garbage collect all repositories

Shouldn't gitea do it automatically in one of above jobs? Forcing admin to run cli for such tasks seems not practical solution.

need some special option, the cron job will run git gc with no options which only remove the old. you can chang it in the config file.
see:
https://stackoverflow.com/questions/3797907/how-to-remove-unused-objects-from-a-git-repository

@a1012112796 commented on GitHub (Feb 18, 2021): > > you need run git gc in server repo > > So whats the purpose of cron jobs > > ``` > Clean-up deleted branches > Garbage collect all repositories > ``` > > Shouldn't gitea do it automatically in one of above jobs? Forcing admin to run cli for such tasks seems not practical solution. need some special option, the cron job will run ``git gc`` with no options which only remove the old. you can chang it in the config file. see: https://stackoverflow.com/questions/3797907/how-to-remove-unused-objects-from-a-git-repository
Author
Owner

@lunny commented on GitHub (Feb 18, 2021):

It seems git gc is not work but git gc --prune=now did. You can change your configuration file

[cron.git_gc_repos]
ENABLED = true
RUN_AT_START = false
NO_SUCCESS_NOTICE = false
SCHEDULE = @every 72h
TIMEOUT = 60s
; Arguments for command 'git gc'
; The default value is same with [git] -> GC_ARGS
ARGS =  `--prune=now`
@lunny commented on GitHub (Feb 18, 2021): It seems `git gc` is not work but `git gc --prune=now` did. You can change your configuration file ```ini [cron.git_gc_repos] ENABLED = true RUN_AT_START = false NO_SUCCESS_NOTICE = false SCHEDULE = @every 72h TIMEOUT = 60s ; Arguments for command 'git gc' ; The default value is same with [git] -> GC_ARGS ARGS = `--prune=now` ```
Author
Owner

@pboguslawski commented on GitHub (Feb 18, 2021):

Just tested that running manually git gc --prune=1.hour.ago removed this commit so default gitea job configuration ( prune is 2 weeks by default according to https://git-scm.com/docs/git-gc#Documentation/git-gc.txt---pruneltdategt ) with fine-tune option using GC_ARGS seems optimal.

Thanks for help!

@pboguslawski commented on GitHub (Feb 18, 2021): Just tested that running manually `git gc --prune=1.hour.ago` removed this commit so default gitea job configuration ( prune is 2 weeks by default according to https://git-scm.com/docs/git-gc#Documentation/git-gc.txt---pruneltdategt ) with fine-tune option using `GC_ARGS` seems optimal. Thanks for help!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#6894