You are not logged in.

#1 2013-03-27 12:57:27

cra
Member
From: Sweden
Registered: 2009-09-25
Posts: 70

[SOLVED] Having config repo in my home dir: ~/.git becomes too big

Hi all!

A while ago I had an idea to have my computer track my config files for me, so now I have a small repository for my configs which I store in git (and on bitbucket).
What I actually noticed that the ~/.git folder becomes bloated (right now it takes around 364 Mb, and on my laptop it was a few Gb actually.. For around a megabyte of text files)

Sooo.. I'm not a git guru, this behavior seems strange and I don't know how to fix that. Am I just doing something strange and using a wrong tool here?

Last edited by cra (2013-04-04 12:55:33)


Thou shalt not make a machine in the likeness of a human mind

Offline

#2 2013-03-27 13:27:11

WorMzy
Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 11,835
Website

Re: [SOLVED] Having config repo in my home dir: ~/.git becomes too big

See if gc helps:

git gc

For me it shrank my .git size considerably:

$ du -hxd 0 .git 
480K    .git
$ git gc
Counting objects: 92, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (90/90), done.
Writing objects: 100% (92/92), done.
Total 92 (delta 41), reused 0 (delta 0)
$ sync  
$ du -hxd 0 .git
112K    .git

'man git-gc' for more information, options, etc.


Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.

Offline

#3 2013-03-27 13:41:33

jakobcreutzfeldt
Member
Registered: 2011-05-12
Posts: 1,041

Re: [SOLVED] Having config repo in my home dir: ~/.git becomes too big

Another option, which I think more people do, is to store their config files under a separate directory and then use a tool to symlink those files back into their home directory. Then you only have to keep that specific config file directory under version control.

For example, I have a directory called dotfiles, and under it are directories for each program. Each program directory has all of its dotfiles laid out exactly as they would be laid out in my home directory. So, for example:

/home/brandon/dotfiles/
    bash/
        .bashrc
        .bash_profile
    newsbeuter/
        .config/newsbeuter/urls

I keep the dotfiles directory under version control.

I then use Stow to create symlinks back into my home directory:

$ stow bash
$ stow newsbeuter
$ ls -l ~/.bash_rc
lrwxrwxrwx 1 brandon users 1K Nov  8 16:41 /home/brandon/.bashrc -> dotfiles/bash/.bashrc

When you set up a new system, you only need to stow the programs you actually need. So, for example, I don't use vim anymore but I still have my config files. If I ever decide to switch back, I just need to stow vim to have them back. Until then, they're tucked neatly away, not cluttering up my home directory.

This will spare you from having git worry about every file in your home directory.

Last edited by jakobcreutzfeldt (2013-03-27 13:44:43)

Offline

#4 2013-03-27 13:48:42

cra
Member
From: Sweden
Registered: 2009-09-25
Posts: 70

Re: [SOLVED] Having config repo in my home dir: ~/.git becomes too big

Well, it did something, but not much..

[cra@hannelore 14:42:44 ~]
 $ du -hs .git
364M	.git
[cra@hannelore 14:42:50 ~]
 $ du -hxd 0 .git
364M	.git
[cra@hannelore 14:42:54 ~]
 $ git gc
Counting objects: 86, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (79/79), done.
Writing objects: 100% (86/86), done.
Total 86 (delta 21), reused 0 (delta 0)
[cra@hannelore 14:42:57 ~]
 $ du -hxd 0 .git
240M	.git
[cra@hannelore 14:42:59 ~]
 $ sync
[cra@hannelore 14:43:04 ~]
 $ du -hxd 0 .git
240M	.git
[cra@hannelore 14:43:05 ~]
 $ 

Also 'git status' shows a lot of files I haven't added myself (??) as "new files" under "Changes to be commited".
And 'gitk --all' shows a fun entry "Local changes checked in to index but not committed". I'm puzzled %)


Thou shalt not make a machine in the likeness of a human mind

Offline

#5 2013-03-27 13:52:35

cra
Member
From: Sweden
Registered: 2009-09-25
Posts: 70

Re: [SOLVED] Having config repo in my home dir: ~/.git becomes too big

jakobcreutzfeldt wrote:

Another option, which I think more people do, is to store their config files under a separate directory and then use a tool to symlink those files back into their home directory. Then you only have to keep that specific config file directory under version control.
[...]
I then use Stow to create symlinks back into my home directory
[...]
This will spare you from having git worry about every file in your home directory.

This workflow sounds much more convenient, thanks for sharing!
So, just to make sure I got it right: you have a separate folder just for dotfiles which is actually in your git repo or some other cvs, and your local actual config files are not tracked?


Thou shalt not make a machine in the likeness of a human mind

Offline

#6 2013-03-27 14:19:43

jakobcreutzfeldt
Member
Registered: 2011-05-12
Posts: 1,041

Re: [SOLVED] Having config repo in my home dir: ~/.git becomes too big

cra wrote:

This workflow sounds much more convenient, thanks for sharing!
So, just to make sure I got it right: you have a separate folder just for dotfiles which is actually in your git repo or some other cvs, and your local actual config files are not tracked?

Right. Basically:

$ cd ~
$ mkdir dotfiles
$ cd dotfiles
$ git init
$ mkdir bash
$ mv ../{.bashrc,.bash_profile} bash
$ git add bash 
$ git commit
$ stow bash

...and so on.

I forgot to mention that it's also easy to clean up. Say you don't want the config files of a program anymore, you just do stow -D program to remove the symlinks.

Offline

#7 2013-03-27 14:52:00

jakobcreutzfeldt
Member
Registered: 2011-05-12
Posts: 1,041

Re: [SOLVED] Having config repo in my home dir: ~/.git becomes too big

Also note that there are 5 or 6 million tools to accomplish similar things but I found most of them to be complete overkill. I don't want to have to learn a ton of commands for a tool that I won't use very often. I also don't want to have to install a ton of  Ruby dependencies to do it. I found Stow to be the simplest solution, short of doing the symlinking myself. Anyway, have a look around, you might find a different solution that suits your needs/style better.

Offline

#8 2013-03-27 15:53:28

SanskritFritz
Member
From: Budapest, Hungary
Registered: 2009-01-08
Posts: 1,924
Website

Re: [SOLVED] Having config repo in my home dir: ~/.git becomes too big

jakobcreutzfeldt wrote:

So, for example, I don't use vim anymore

This example will get you banned on this forum. Careful there big_smile
Anyway, nice workflow, thank you!


zʇıɹɟʇıɹʞsuɐs AUR || Cycling in Budapest with a helmet camera || Revised log levels proposal: "FYI" "WTF" and "OMG" (John Barnette)

Offline

#9 2013-04-04 12:55:08

cra
Member
From: Sweden
Registered: 2009-09-25
Posts: 70

Re: [SOLVED] Having config repo in my home dir: ~/.git becomes too big

Cool. It works, I love the simplicity of stow smile
Thanks!


Thou shalt not make a machine in the likeness of a human mind

Offline

Board footer

Powered by FluxBB