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?
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
|
show 1 more comment
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
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 increasinggc.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 rungit 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
|
show 1 more comment
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
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
git garbage-collection
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 increasinggc.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 rungit 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
|
show 1 more comment
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 increasinggc.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 rungit 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
|
show 1 more comment
2 Answers
2
active
oldest
votes
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
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
add a comment |
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.
2
This is much better that settinggc.auto
to zero becausegc
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 encounterwarning: There are too many unreachable loose objects; run 'git prune' to remove them.
if you use configuration valuenever
. In that case you probably want to setgc.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 increasinggc.auto
is just a workaround. If I understand the code ingc.c
of git source correctly, highgc.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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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
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
add a comment |
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
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
add a comment |
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
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
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
add a comment |
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
add a comment |
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.
2
This is much better that settinggc.auto
to zero becausegc
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 encounterwarning: There are too many unreachable loose objects; run 'git prune' to remove them.
if you use configuration valuenever
. In that case you probably want to setgc.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 increasinggc.auto
is just a workaround. If I understand the code ingc.c
of git source correctly, highgc.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
add a comment |
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.
2
This is much better that settinggc.auto
to zero becausegc
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 encounterwarning: There are too many unreachable loose objects; run 'git prune' to remove them.
if you use configuration valuenever
. In that case you probably want to setgc.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 increasinggc.auto
is just a workaround. If I understand the code ingc.c
of git source correctly, highgc.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
add a comment |
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.
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.
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 settinggc.auto
to zero becausegc
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 encounterwarning: There are too many unreachable loose objects; run 'git prune' to remove them.
if you use configuration valuenever
. In that case you probably want to setgc.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 increasinggc.auto
is just a workaround. If I understand the code ingc.c
of git source correctly, highgc.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
add a comment |
2
This is much better that settinggc.auto
to zero becausegc
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 encounterwarning: There are too many unreachable loose objects; run 'git prune' to remove them.
if you use configuration valuenever
. In that case you probably want to setgc.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 increasinggc.auto
is just a workaround. If I understand the code ingc.c
of git source correctly, highgc.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
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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