How to Prevent Garbage Collection in GIT?2019 Community Moderator ElectionBitbucket garbage collection process slows down server performanceIs it possible to get `git gc` to pack reflog objects?Index.lock missing for gtihub desktopHow do I discard unstaged changes in Git?How to remove local (untracked) files from the current Git working tree?How to modify existing, unpushed commits?What is the difference between 'git pull' and 'git fetch'?How to undo 'git add' before commit?How do I undo the most recent commits in Git?How do I check out a remote Git branch?How do I delete a Git branch both locally and remotely?How to revert a Git repository to a previous commitHow do I rename a local Git branch?

How to generate globally unique ids for different tables of the same database?

Does this property of comaximal ideals always holds?

Dot in front of file

Calculus II Professor will not accept my correct integral evaluation that uses a different method, should I bring this up further?

How to answer questions about my characters?

Professor being mistaken for a grad student

Is having access to past exams cheating and, if yes, could it be proven just by a good grade?

Informing my boss about remarks from a nasty colleague

How to explain that I do not want to visit a country due to personal safety concern?

Should we release the security issues we found in our product as CVE or we can just update those on weekly release notes?

Possible Leak In Concrete

Identifying the interval from A♭ to D♯

Can hydraulic brake levers get hot when brakes overheat?

Why are there 40 737 Max planes in flight when they have been grounded as not airworthy?

What are some nice/clever ways to introduce the tonic's dominant seventh chord?

Ban on all campaign finance?

How can I change step-down my variable input voltage? [Microcontroller]

Unreachable code, but reachable with exception

The use of "touch" and "touch on" in context

Does splitting a potentially monolithic application into several smaller ones help prevent bugs?

How to simplify this time periods definition interface?

Sword in the Stone story where the sword was held in place by electromagnets

Where is the 1/8 CR apprentice in Volo's Guide to Monsters?

Meaning of "SEVERA INDEOVI VAS" from 3rd Century slab



How to Prevent Garbage Collection in GIT?



2019 Community Moderator ElectionBitbucket garbage collection process slows down server performanceIs it possible to get `git gc` to pack reflog objects?Index.lock missing for gtihub desktopHow do I discard unstaged changes in Git?How to remove local (untracked) files from the current Git working tree?How to modify existing, unpushed commits?What is the difference between 'git pull' and 'git fetch'?How to undo 'git add' before commit?How do I undo the most recent commits in Git?How do I check out a remote Git branch?How do I delete a Git branch both locally and remotely?How to revert a Git repository to a previous commitHow do I rename a local Git branch?










18















Git mysteriously runs Garbage collection "from time to time" and deletes and orphaned commits you have.



https://www.kernel.org/pub/software/scm/git/docs/git-gc.html



Scientifically, this will occur approximately 6-8 hours before you realize you really needed that commit which was just deleted.



I'd rather not have my files deleted by Git. How can I disable automatic garbage collection altogether?










share|improve this question

















  • 4





    In standard configuration, it will only delete commits that have been orphaned (i.e. not been accessible from the history of any branch) for more than 90 days. It doesn't "delete your files". It stops preserving things that you have deleted months ago.

    – Sven Marnach
    Jan 22 '15 at 15:51






  • 1





    A lot of the time I might unwittingly destroy the path to a commit and orphan it by doing a rebase. My intent isn't really to delete this info.

    – Code Whisperer
    Jan 22 '15 at 15:58






  • 4





    Fair enough -- that's a reasonable preference. I personally prefer a workflow that simply keeps things I might still need in the history. I would suggest increasing gc.reflogexpire and friends as well for your use case, since this will make finding abandoned commits easier. It is worth noting that never running garbage collection might decrease git's performance.

    – Sven Marnach
    Jan 22 '15 at 16:10







  • 2





    Even after a rebase, your old commits are preserved thanks to the reflog. To give yourself an easier out, before your rebase run git checkout -b mulligan.

    – Greg Bacon
    Jan 22 '15 at 16:12






  • 1





    @GregBacon Doing this will successfully prevent commits from being marked as garbage

    – Code Whisperer
    Jan 22 '15 at 16:14















18















Git mysteriously runs Garbage collection "from time to time" and deletes and orphaned commits you have.



https://www.kernel.org/pub/software/scm/git/docs/git-gc.html



Scientifically, this will occur approximately 6-8 hours before you realize you really needed that commit which was just deleted.



I'd rather not have my files deleted by Git. How can I disable automatic garbage collection altogether?










share|improve this question

















  • 4





    In standard configuration, it will only delete commits that have been orphaned (i.e. not been accessible from the history of any branch) for more than 90 days. It doesn't "delete your files". It stops preserving things that you have deleted months ago.

    – Sven Marnach
    Jan 22 '15 at 15:51






  • 1





    A lot of the time I might unwittingly destroy the path to a commit and orphan it by doing a rebase. My intent isn't really to delete this info.

    – Code Whisperer
    Jan 22 '15 at 15:58






  • 4





    Fair enough -- that's a reasonable preference. I personally prefer a workflow that simply keeps things I might still need in the history. I would suggest increasing gc.reflogexpire and friends as well for your use case, since this will make finding abandoned commits easier. It is worth noting that never running garbage collection might decrease git's performance.

    – Sven Marnach
    Jan 22 '15 at 16:10







  • 2





    Even after a rebase, your old commits are preserved thanks to the reflog. To give yourself an easier out, before your rebase run git checkout -b mulligan.

    – Greg Bacon
    Jan 22 '15 at 16:12






  • 1





    @GregBacon Doing this will successfully prevent commits from being marked as garbage

    – Code Whisperer
    Jan 22 '15 at 16:14













18












18








18


2






Git mysteriously runs Garbage collection "from time to time" and deletes and orphaned commits you have.



https://www.kernel.org/pub/software/scm/git/docs/git-gc.html



Scientifically, this will occur approximately 6-8 hours before you realize you really needed that commit which was just deleted.



I'd rather not have my files deleted by Git. How can I disable automatic garbage collection altogether?










share|improve this question














Git mysteriously runs Garbage collection "from time to time" and deletes and orphaned commits you have.



https://www.kernel.org/pub/software/scm/git/docs/git-gc.html



Scientifically, this will occur approximately 6-8 hours before you realize you really needed that commit which was just deleted.



I'd rather not have my files deleted by Git. How can I disable automatic garbage collection altogether?







git garbage-collection






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 22 '15 at 15:26









Code WhispererCode Whisperer

12.7k154364




12.7k154364







  • 4





    In standard configuration, it will only delete commits that have been orphaned (i.e. not been accessible from the history of any branch) for more than 90 days. It doesn't "delete your files". It stops preserving things that you have deleted months ago.

    – Sven Marnach
    Jan 22 '15 at 15:51






  • 1





    A lot of the time I might unwittingly destroy the path to a commit and orphan it by doing a rebase. My intent isn't really to delete this info.

    – Code Whisperer
    Jan 22 '15 at 15:58






  • 4





    Fair enough -- that's a reasonable preference. I personally prefer a workflow that simply keeps things I might still need in the history. I would suggest increasing gc.reflogexpire and friends as well for your use case, since this will make finding abandoned commits easier. It is worth noting that never running garbage collection might decrease git's performance.

    – Sven Marnach
    Jan 22 '15 at 16:10







  • 2





    Even after a rebase, your old commits are preserved thanks to the reflog. To give yourself an easier out, before your rebase run git checkout -b mulligan.

    – Greg Bacon
    Jan 22 '15 at 16:12






  • 1





    @GregBacon Doing this will successfully prevent commits from being marked as garbage

    – Code Whisperer
    Jan 22 '15 at 16:14












  • 4





    In standard configuration, it will only delete commits that have been orphaned (i.e. not been accessible from the history of any branch) for more than 90 days. It doesn't "delete your files". It stops preserving things that you have deleted months ago.

    – Sven Marnach
    Jan 22 '15 at 15:51






  • 1





    A lot of the time I might unwittingly destroy the path to a commit and orphan it by doing a rebase. My intent isn't really to delete this info.

    – Code Whisperer
    Jan 22 '15 at 15:58






  • 4





    Fair enough -- that's a reasonable preference. I personally prefer a workflow that simply keeps things I might still need in the history. I would suggest increasing gc.reflogexpire and friends as well for your use case, since this will make finding abandoned commits easier. It is worth noting that never running garbage collection might decrease git's performance.

    – Sven Marnach
    Jan 22 '15 at 16:10







  • 2





    Even after a rebase, your old commits are preserved thanks to the reflog. To give yourself an easier out, before your rebase run git checkout -b mulligan.

    – Greg Bacon
    Jan 22 '15 at 16:12






  • 1





    @GregBacon Doing this will successfully prevent commits from being marked as garbage

    – Code Whisperer
    Jan 22 '15 at 16:14







4




4





In standard configuration, it will only delete commits that have been orphaned (i.e. not been accessible from the history of any branch) for more than 90 days. It doesn't "delete your files". It stops preserving things that you have deleted months ago.

– Sven Marnach
Jan 22 '15 at 15:51





In standard configuration, it will only delete commits that have been orphaned (i.e. not been accessible from the history of any branch) for more than 90 days. It doesn't "delete your files". It stops preserving things that you have deleted months ago.

– Sven Marnach
Jan 22 '15 at 15:51




1




1





A lot of the time I might unwittingly destroy the path to a commit and orphan it by doing a rebase. My intent isn't really to delete this info.

– Code Whisperer
Jan 22 '15 at 15:58





A lot of the time I might unwittingly destroy the path to a commit and orphan it by doing a rebase. My intent isn't really to delete this info.

– Code Whisperer
Jan 22 '15 at 15:58




4




4





Fair enough -- that's a reasonable preference. I personally prefer a workflow that simply keeps things I might still need in the history. I would suggest increasing gc.reflogexpire and friends as well for your use case, since this will make finding abandoned commits easier. It is worth noting that never running garbage collection might decrease git's performance.

– Sven Marnach
Jan 22 '15 at 16:10






Fair enough -- that's a reasonable preference. I personally prefer a workflow that simply keeps things I might still need in the history. I would suggest increasing gc.reflogexpire and friends as well for your use case, since this will make finding abandoned commits easier. It is worth noting that never running garbage collection might decrease git's performance.

– Sven Marnach
Jan 22 '15 at 16:10





2




2





Even after a rebase, your old commits are preserved thanks to the reflog. To give yourself an easier out, before your rebase run git checkout -b mulligan.

– Greg Bacon
Jan 22 '15 at 16:12





Even after a rebase, your old commits are preserved thanks to the reflog. To give yourself an easier out, before your rebase run git checkout -b mulligan.

– Greg Bacon
Jan 22 '15 at 16:12




1




1





@GregBacon Doing this will successfully prevent commits from being marked as garbage

– Code Whisperer
Jan 22 '15 at 16:14





@GregBacon Doing this will successfully prevent commits from being marked as garbage

– Code Whisperer
Jan 22 '15 at 16:14












2 Answers
2






active

oldest

votes


















23














From the very same page you just linked to:




Some git commands may automatically run git gc; see the --auto flag below for details. If you know what you’re doing and all you want is to disable this behavior permanently without further considerations, just do:



$ git config --global gc.auto 0






share|improve this answer























  • Well ain't that the ticket

    – Code Whisperer
    Jan 22 '15 at 15:30











  • All it tells me is "bash: git: command not found" Using git extensions

    – Hatchling
    Aug 24 '16 at 19:05






  • 3





    @Hatchling: Sounds like you need to install git.

    – SLaks
    Aug 25 '16 at 14:54











  • @SLaks I had to use the default bash console provided by git itself. The GitExtensions console seems to not recognize some commands.

    – Hatchling
    Aug 25 '16 at 21:31






  • 1





    What the quoted paragraph does not tell us is whether this is the only mechanism by which gc happens. The OP says "Git mysteriously runs Garbage collection 'from time to time'", giving the impression that gc may also happen without being triggered by the user issuing any git commands. Assurance that this doesn't actually happen would fill in the gap in this answer.

    – LarsH
    Feb 27 '18 at 14:58



















5














Another approach, recently documented in:
Documentation/config: mention "now" and "never" for 'expire' settings




In addition to approxidate-style values ("2.months.ago", "yesterday"),
consumers of 'gc.*expire*' configuration variables also accept and
respect 'now' ("do it immediately") and 'never' ("suppress entirely").




See commit 8cc8816 (28 Jul 2015) by Eric Sunshine (sunshineco).

Suggested-by: Michael Haggerty (mhagger).
(Merged by Junio C Hamano -- gitster -- in commit 8cc8816, 28 Jul 2015)



That means this would also prevent any gc:



git config --global gc.pruneExpire never
git config --global gc.reflogExpire never


However, you may encounter (if you use configuration value never):



warning: There are too many unreachable loose objects; run 'git prune' to remove them. 


In that case, you probably want to set gc.auto to some high value (e.g. 100000) if you really do not want to expire anything. That will silence the warning but may cause garbage collection to be less effective overall so this should be considered as a workaround, not a real fix. See Is it possible to get `git gc` to pack reflog objects? for additional details.






share|improve this answer




















  • 2





    This is much better that setting gc.auto to zero because gc will e.g. automatically repack the objects to improve performance. You really want gc but you do not want to expire stuff, which is exactly these configuration parameters do.

    – Mikko Rantalainen
    Oct 25 '18 at 7:43











  • However, you may encounter warning: There are too many unreachable loose objects; run 'git prune' to remove them. if you use configuration value never. In that case you probably want to set gc.auto to some high value (e.g. 100000) if you really do not want to expire anything.

    – Mikko Rantalainen
    Mar 7 at 11:58












  • @MikkoRantalainen Thank you. I have included your comment in the answer for more visibility.

    – VonC
    Mar 7 at 12:30











  • It might we nice to mention that increasing gc.auto is just a workaround. If I understand the code in gc.c of git source correctly, high gc.auto value may prevent automatic gc (including compressing normal stuff) to be skipped, too. See also: stackoverflow.com/q/55043693/334451

    – Mikko Rantalainen
    Mar 7 at 12:57











  • @MikkoRantalainen by all means, do edit this answer to include what you deem relevant.

    – VonC
    Mar 7 at 14:01










Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f28092485%2fhow-to-prevent-garbage-collection-in-git%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









23














From the very same page you just linked to:




Some git commands may automatically run git gc; see the --auto flag below for details. If you know what you’re doing and all you want is to disable this behavior permanently without further considerations, just do:



$ git config --global gc.auto 0






share|improve this answer























  • Well ain't that the ticket

    – Code Whisperer
    Jan 22 '15 at 15:30











  • All it tells me is "bash: git: command not found" Using git extensions

    – Hatchling
    Aug 24 '16 at 19:05






  • 3





    @Hatchling: Sounds like you need to install git.

    – SLaks
    Aug 25 '16 at 14:54











  • @SLaks I had to use the default bash console provided by git itself. The GitExtensions console seems to not recognize some commands.

    – Hatchling
    Aug 25 '16 at 21:31






  • 1





    What the quoted paragraph does not tell us is whether this is the only mechanism by which gc happens. The OP says "Git mysteriously runs Garbage collection 'from time to time'", giving the impression that gc may also happen without being triggered by the user issuing any git commands. Assurance that this doesn't actually happen would fill in the gap in this answer.

    – LarsH
    Feb 27 '18 at 14:58
















23














From the very same page you just linked to:




Some git commands may automatically run git gc; see the --auto flag below for details. If you know what you’re doing and all you want is to disable this behavior permanently without further considerations, just do:



$ git config --global gc.auto 0






share|improve this answer























  • Well ain't that the ticket

    – Code Whisperer
    Jan 22 '15 at 15:30











  • All it tells me is "bash: git: command not found" Using git extensions

    – Hatchling
    Aug 24 '16 at 19:05






  • 3





    @Hatchling: Sounds like you need to install git.

    – SLaks
    Aug 25 '16 at 14:54











  • @SLaks I had to use the default bash console provided by git itself. The GitExtensions console seems to not recognize some commands.

    – Hatchling
    Aug 25 '16 at 21:31






  • 1





    What the quoted paragraph does not tell us is whether this is the only mechanism by which gc happens. The OP says "Git mysteriously runs Garbage collection 'from time to time'", giving the impression that gc may also happen without being triggered by the user issuing any git commands. Assurance that this doesn't actually happen would fill in the gap in this answer.

    – LarsH
    Feb 27 '18 at 14:58














23












23








23







From the very same page you just linked to:




Some git commands may automatically run git gc; see the --auto flag below for details. If you know what you’re doing and all you want is to disable this behavior permanently without further considerations, just do:



$ git config --global gc.auto 0






share|improve this answer













From the very same page you just linked to:




Some git commands may automatically run git gc; see the --auto flag below for details. If you know what you’re doing and all you want is to disable this behavior permanently without further considerations, just do:



$ git config --global gc.auto 0







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 22 '15 at 15:29









SLaksSLaks

689k13916461768




689k13916461768












  • Well ain't that the ticket

    – Code Whisperer
    Jan 22 '15 at 15:30











  • All it tells me is "bash: git: command not found" Using git extensions

    – Hatchling
    Aug 24 '16 at 19:05






  • 3





    @Hatchling: Sounds like you need to install git.

    – SLaks
    Aug 25 '16 at 14:54











  • @SLaks I had to use the default bash console provided by git itself. The GitExtensions console seems to not recognize some commands.

    – Hatchling
    Aug 25 '16 at 21:31






  • 1





    What the quoted paragraph does not tell us is whether this is the only mechanism by which gc happens. The OP says "Git mysteriously runs Garbage collection 'from time to time'", giving the impression that gc may also happen without being triggered by the user issuing any git commands. Assurance that this doesn't actually happen would fill in the gap in this answer.

    – LarsH
    Feb 27 '18 at 14:58


















  • Well ain't that the ticket

    – Code Whisperer
    Jan 22 '15 at 15:30











  • All it tells me is "bash: git: command not found" Using git extensions

    – Hatchling
    Aug 24 '16 at 19:05






  • 3





    @Hatchling: Sounds like you need to install git.

    – SLaks
    Aug 25 '16 at 14:54











  • @SLaks I had to use the default bash console provided by git itself. The GitExtensions console seems to not recognize some commands.

    – Hatchling
    Aug 25 '16 at 21:31






  • 1





    What the quoted paragraph does not tell us is whether this is the only mechanism by which gc happens. The OP says "Git mysteriously runs Garbage collection 'from time to time'", giving the impression that gc may also happen without being triggered by the user issuing any git commands. Assurance that this doesn't actually happen would fill in the gap in this answer.

    – LarsH
    Feb 27 '18 at 14:58

















Well ain't that the ticket

– Code Whisperer
Jan 22 '15 at 15:30





Well ain't that the ticket

– Code Whisperer
Jan 22 '15 at 15:30













All it tells me is "bash: git: command not found" Using git extensions

– Hatchling
Aug 24 '16 at 19:05





All it tells me is "bash: git: command not found" Using git extensions

– Hatchling
Aug 24 '16 at 19:05




3




3





@Hatchling: Sounds like you need to install git.

– SLaks
Aug 25 '16 at 14:54





@Hatchling: Sounds like you need to install git.

– SLaks
Aug 25 '16 at 14:54













@SLaks I had to use the default bash console provided by git itself. The GitExtensions console seems to not recognize some commands.

– Hatchling
Aug 25 '16 at 21:31





@SLaks I had to use the default bash console provided by git itself. The GitExtensions console seems to not recognize some commands.

– Hatchling
Aug 25 '16 at 21:31




1




1





What the quoted paragraph does not tell us is whether this is the only mechanism by which gc happens. The OP says "Git mysteriously runs Garbage collection 'from time to time'", giving the impression that gc may also happen without being triggered by the user issuing any git commands. Assurance that this doesn't actually happen would fill in the gap in this answer.

– LarsH
Feb 27 '18 at 14:58






What the quoted paragraph does not tell us is whether this is the only mechanism by which gc happens. The OP says "Git mysteriously runs Garbage collection 'from time to time'", giving the impression that gc may also happen without being triggered by the user issuing any git commands. Assurance that this doesn't actually happen would fill in the gap in this answer.

– LarsH
Feb 27 '18 at 14:58














5














Another approach, recently documented in:
Documentation/config: mention "now" and "never" for 'expire' settings




In addition to approxidate-style values ("2.months.ago", "yesterday"),
consumers of 'gc.*expire*' configuration variables also accept and
respect 'now' ("do it immediately") and 'never' ("suppress entirely").




See commit 8cc8816 (28 Jul 2015) by Eric Sunshine (sunshineco).

Suggested-by: Michael Haggerty (mhagger).
(Merged by Junio C Hamano -- gitster -- in commit 8cc8816, 28 Jul 2015)



That means this would also prevent any gc:



git config --global gc.pruneExpire never
git config --global gc.reflogExpire never


However, you may encounter (if you use configuration value never):



warning: There are too many unreachable loose objects; run 'git prune' to remove them. 


In that case, you probably want to set gc.auto to some high value (e.g. 100000) if you really do not want to expire anything. That will silence the warning but may cause garbage collection to be less effective overall so this should be considered as a workaround, not a real fix. See Is it possible to get `git gc` to pack reflog objects? for additional details.






share|improve this answer




















  • 2





    This is much better that setting gc.auto to zero because gc will e.g. automatically repack the objects to improve performance. You really want gc but you do not want to expire stuff, which is exactly these configuration parameters do.

    – Mikko Rantalainen
    Oct 25 '18 at 7:43











  • However, you may encounter warning: There are too many unreachable loose objects; run 'git prune' to remove them. if you use configuration value never. In that case you probably want to set gc.auto to some high value (e.g. 100000) if you really do not want to expire anything.

    – Mikko Rantalainen
    Mar 7 at 11:58












  • @MikkoRantalainen Thank you. I have included your comment in the answer for more visibility.

    – VonC
    Mar 7 at 12:30











  • It might we nice to mention that increasing gc.auto is just a workaround. If I understand the code in gc.c of git source correctly, high gc.auto value may prevent automatic gc (including compressing normal stuff) to be skipped, too. See also: stackoverflow.com/q/55043693/334451

    – Mikko Rantalainen
    Mar 7 at 12:57











  • @MikkoRantalainen by all means, do edit this answer to include what you deem relevant.

    – VonC
    Mar 7 at 14:01















5














Another approach, recently documented in:
Documentation/config: mention "now" and "never" for 'expire' settings




In addition to approxidate-style values ("2.months.ago", "yesterday"),
consumers of 'gc.*expire*' configuration variables also accept and
respect 'now' ("do it immediately") and 'never' ("suppress entirely").




See commit 8cc8816 (28 Jul 2015) by Eric Sunshine (sunshineco).

Suggested-by: Michael Haggerty (mhagger).
(Merged by Junio C Hamano -- gitster -- in commit 8cc8816, 28 Jul 2015)



That means this would also prevent any gc:



git config --global gc.pruneExpire never
git config --global gc.reflogExpire never


However, you may encounter (if you use configuration value never):



warning: There are too many unreachable loose objects; run 'git prune' to remove them. 


In that case, you probably want to set gc.auto to some high value (e.g. 100000) if you really do not want to expire anything. That will silence the warning but may cause garbage collection to be less effective overall so this should be considered as a workaround, not a real fix. See Is it possible to get `git gc` to pack reflog objects? for additional details.






share|improve this answer




















  • 2





    This is much better that setting gc.auto to zero because gc will e.g. automatically repack the objects to improve performance. You really want gc but you do not want to expire stuff, which is exactly these configuration parameters do.

    – Mikko Rantalainen
    Oct 25 '18 at 7:43











  • However, you may encounter warning: There are too many unreachable loose objects; run 'git prune' to remove them. if you use configuration value never. In that case you probably want to set gc.auto to some high value (e.g. 100000) if you really do not want to expire anything.

    – Mikko Rantalainen
    Mar 7 at 11:58












  • @MikkoRantalainen Thank you. I have included your comment in the answer for more visibility.

    – VonC
    Mar 7 at 12:30











  • It might we nice to mention that increasing gc.auto is just a workaround. If I understand the code in gc.c of git source correctly, high gc.auto value may prevent automatic gc (including compressing normal stuff) to be skipped, too. See also: stackoverflow.com/q/55043693/334451

    – Mikko Rantalainen
    Mar 7 at 12:57











  • @MikkoRantalainen by all means, do edit this answer to include what you deem relevant.

    – VonC
    Mar 7 at 14:01













5












5








5







Another approach, recently documented in:
Documentation/config: mention "now" and "never" for 'expire' settings




In addition to approxidate-style values ("2.months.ago", "yesterday"),
consumers of 'gc.*expire*' configuration variables also accept and
respect 'now' ("do it immediately") and 'never' ("suppress entirely").




See commit 8cc8816 (28 Jul 2015) by Eric Sunshine (sunshineco).

Suggested-by: Michael Haggerty (mhagger).
(Merged by Junio C Hamano -- gitster -- in commit 8cc8816, 28 Jul 2015)



That means this would also prevent any gc:



git config --global gc.pruneExpire never
git config --global gc.reflogExpire never


However, you may encounter (if you use configuration value never):



warning: There are too many unreachable loose objects; run 'git prune' to remove them. 


In that case, you probably want to set gc.auto to some high value (e.g. 100000) if you really do not want to expire anything. That will silence the warning but may cause garbage collection to be less effective overall so this should be considered as a workaround, not a real fix. See Is it possible to get `git gc` to pack reflog objects? for additional details.






share|improve this answer















Another approach, recently documented in:
Documentation/config: mention "now" and "never" for 'expire' settings




In addition to approxidate-style values ("2.months.ago", "yesterday"),
consumers of 'gc.*expire*' configuration variables also accept and
respect 'now' ("do it immediately") and 'never' ("suppress entirely").




See commit 8cc8816 (28 Jul 2015) by Eric Sunshine (sunshineco).

Suggested-by: Michael Haggerty (mhagger).
(Merged by Junio C Hamano -- gitster -- in commit 8cc8816, 28 Jul 2015)



That means this would also prevent any gc:



git config --global gc.pruneExpire never
git config --global gc.reflogExpire never


However, you may encounter (if you use configuration value never):



warning: There are too many unreachable loose objects; run 'git prune' to remove them. 


In that case, you probably want to set gc.auto to some high value (e.g. 100000) if you really do not want to expire anything. That will silence the warning but may cause garbage collection to be less effective overall so this should be considered as a workaround, not a real fix. See Is it possible to get `git gc` to pack reflog objects? for additional details.







share|improve this answer














share|improve this answer



share|improve this answer








edited Mar 8 at 6:54









Mikko Rantalainen

6,04753968




6,04753968










answered Aug 15 '15 at 14:33









VonCVonC

847k29626953252




847k29626953252







  • 2





    This is much better that setting gc.auto to zero because gc will e.g. automatically repack the objects to improve performance. You really want gc but you do not want to expire stuff, which is exactly these configuration parameters do.

    – Mikko Rantalainen
    Oct 25 '18 at 7:43











  • However, you may encounter warning: There are too many unreachable loose objects; run 'git prune' to remove them. if you use configuration value never. In that case you probably want to set gc.auto to some high value (e.g. 100000) if you really do not want to expire anything.

    – Mikko Rantalainen
    Mar 7 at 11:58












  • @MikkoRantalainen Thank you. I have included your comment in the answer for more visibility.

    – VonC
    Mar 7 at 12:30











  • It might we nice to mention that increasing gc.auto is just a workaround. If I understand the code in gc.c of git source correctly, high gc.auto value may prevent automatic gc (including compressing normal stuff) to be skipped, too. See also: stackoverflow.com/q/55043693/334451

    – Mikko Rantalainen
    Mar 7 at 12:57











  • @MikkoRantalainen by all means, do edit this answer to include what you deem relevant.

    – VonC
    Mar 7 at 14:01












  • 2





    This is much better that setting gc.auto to zero because gc will e.g. automatically repack the objects to improve performance. You really want gc but you do not want to expire stuff, which is exactly these configuration parameters do.

    – Mikko Rantalainen
    Oct 25 '18 at 7:43











  • However, you may encounter warning: There are too many unreachable loose objects; run 'git prune' to remove them. if you use configuration value never. In that case you probably want to set gc.auto to some high value (e.g. 100000) if you really do not want to expire anything.

    – Mikko Rantalainen
    Mar 7 at 11:58












  • @MikkoRantalainen Thank you. I have included your comment in the answer for more visibility.

    – VonC
    Mar 7 at 12:30











  • It might we nice to mention that increasing gc.auto is just a workaround. If I understand the code in gc.c of git source correctly, high gc.auto value may prevent automatic gc (including compressing normal stuff) to be skipped, too. See also: stackoverflow.com/q/55043693/334451

    – Mikko Rantalainen
    Mar 7 at 12:57











  • @MikkoRantalainen by all means, do edit this answer to include what you deem relevant.

    – VonC
    Mar 7 at 14:01







2




2





This is much better that setting gc.auto to zero because gc will e.g. automatically repack the objects to improve performance. You really want gc but you do not want to expire stuff, which is exactly these configuration parameters do.

– Mikko Rantalainen
Oct 25 '18 at 7:43





This is much better that setting gc.auto to zero because gc will e.g. automatically repack the objects to improve performance. You really want gc but you do not want to expire stuff, which is exactly these configuration parameters do.

– Mikko Rantalainen
Oct 25 '18 at 7:43













However, you may encounter warning: There are too many unreachable loose objects; run 'git prune' to remove them. if you use configuration value never. In that case you probably want to set gc.auto to some high value (e.g. 100000) if you really do not want to expire anything.

– Mikko Rantalainen
Mar 7 at 11:58






However, you may encounter warning: There are too many unreachable loose objects; run 'git prune' to remove them. if you use configuration value never. In that case you probably want to set gc.auto to some high value (e.g. 100000) if you really do not want to expire anything.

– Mikko Rantalainen
Mar 7 at 11:58














@MikkoRantalainen Thank you. I have included your comment in the answer for more visibility.

– VonC
Mar 7 at 12:30





@MikkoRantalainen Thank you. I have included your comment in the answer for more visibility.

– VonC
Mar 7 at 12:30













It might we nice to mention that increasing gc.auto is just a workaround. If I understand the code in gc.c of git source correctly, high gc.auto value may prevent automatic gc (including compressing normal stuff) to be skipped, too. See also: stackoverflow.com/q/55043693/334451

– Mikko Rantalainen
Mar 7 at 12:57





It might we nice to mention that increasing gc.auto is just a workaround. If I understand the code in gc.c of git source correctly, high gc.auto value may prevent automatic gc (including compressing normal stuff) to be skipped, too. See also: stackoverflow.com/q/55043693/334451

– Mikko Rantalainen
Mar 7 at 12:57













@MikkoRantalainen by all means, do edit this answer to include what you deem relevant.

– VonC
Mar 7 at 14:01





@MikkoRantalainen by all means, do edit this answer to include what you deem relevant.

– VonC
Mar 7 at 14:01

















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f28092485%2fhow-to-prevent-garbage-collection-in-git%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Identity Server 4 is not redirecting to Angular app after login2019 Community Moderator ElectionIdentity Server 4 and dockerIdentityserver implicit flow unauthorized_clientIdentityServer Hybrid Flow - Access Token is null after user successful loginIdentity Server to MVC client : Page Redirect After loginLogin with Steam OpenId(oidc-client-js)Identity Server 4+.NET Core 2.0 + IdentityIdentityServer4 post-login redirect not working in Edge browserCall to IdentityServer4 generates System.NullReferenceException: Object reference not set to an instance of an objectIdentityServer4 without HTTPS not workingHow to get Authorization code from identity server without login form

2005 Ahvaz unrest Contents Background Causes Casualties Aftermath See also References Navigation menue"At Least 10 Are Killed by Bombs in Iran""Iran"Archived"Arab-Iranians in Iran to make April 15 'Day of Fury'"State of Mind, State of Order: Reactions to Ethnic Unrest in the Islamic Republic of Iran.10.1111/j.1754-9469.2008.00028.x"Iran hangs Arab separatists"Iran Overview from ArchivedConstitution of the Islamic Republic of Iran"Tehran puzzled by forged 'riots' letter""Iran and its minorities: Down in the second class""Iran: Handling Of Ahvaz Unrest Could End With Televised Confessions""Bombings Rock Iran Ahead of Election""Five die in Iran ethnic clashes""Iran: Need for restraint as anniversary of unrest in Khuzestan approaches"Archived"Iranian Sunni protesters killed in clashes with security forces"Archived

Can't initialize raids on a new ASUS Prime B360M-A motherboard2019 Community Moderator ElectionSimilar to RAID config yet more like mirroring solution?Can't get motherboard serial numberWhy does the BIOS entry point start with a WBINVD instruction?UEFI performance Asus Maximus V Extreme