You are not logged in.
Pages: 1
:: Disclaimer
I found some topics about placing ~ under version control, but none of the threads were specifically about dotfiles.
I'm completely new to Git and version control in general.
:: Problem
I want to version control some configuration files (.bashrc, .vimrc etc.) in ~ using Git. My reasons for this are as follows:
- Easy to backup files and discard changes.
- Share and synchronize configuration files between computers. I want to allow local customizations, more on this later.
Sounds pretty reasonable? The question is, how do I accomplish this? I did a little research, hoping to find a good article that described everything. What I found was a lot of articles[0-5], each describing its own way of using Git for dotfiles.
:: Solution?
I want to find an easy and straightforward way, that still allows flexibility. After some reading, I've come to the following conclusions:
- Having one git repository directly in ~ isn't a good idea. It's better to have one repo for each group of related files (e.g. all vim configuration).
- Some put the files in ~/dotfiles/* and symlink them, often using a script. This sounds rather complicated to me.
- There are already some scripts to handle everything: git-home and git-home-history. However, these seem to handle the whole ~, not specific dotfiles.
- My plan is to have a master branch where the common configuration are stored, and one branch for each computer for local customizations. (I haven't worked with branches before, but this is a pretty good opportunity to learn how, right?).
I like the sound of detached worktrees[5], but while it doesn't use symbolic links, it requires custom tools (scripts/mr tool). Maybe it's easier to go with the symbolic linking approach?
> Which method do you like the most, and are there any common pitfalls to look out for?
-
[0] http://psung.blogspot.com/2007/11/versi … emote.html
[1] http://wiki.debian-community.org/planet … directory/
[2] http://www.silassewell.com/blog/2009/03 … nd-github/
[3] http://robescriva.com/2009/01/manage-yo … -with-git/
[4] http://mnemonikk.org/2009/03/23/finally … n-control/
[5] http://tensixtyone.com/perma/the-versio … -directory
Offline
i think i would just make a single Master for ~, git-ignoring all non-dotfiles:
git help ignore
since there aren't that many dotfiles it isn't really useful to create separate branches. also, since you are always working in a particular branch, you would have to manually rebase them on Master every time (which is a lot of hassle).
Last edited by litemotiv (2009-06-10 17:12:48)
ᶘ ᵒᴥᵒᶅ
Offline
I started with http://daniel.debian.net/documents/cheatpages/git.html http://www-cs-students.stanford.edu/~bl … index.html and http://www.kernel.org/pub/software/scm/ … orial.html.
Symlinks don't work with git how you'd expect (try and you'll see). I made new dir, called git. Then I hardlinked all config files. E.g.:
'ln ~/.vimrc ~/.bahshrc ~/.xinitc ~/git'. And I'm happy
Last edited by cinan (2009-06-10 18:14:46)
Offline
git-home looks promissing. Contrary to most other git-based solutions it stores permissions too.
Offline
- Some put the files in ~/dotfiles/* and symlink them, often using a script. This sounds rather complicated to me.
This can in fact work quite well.
Currently, I got git repos in
.config/vim, .config/zsh and .config/awesome
with some symlinks:
.zshrc -> .config/zsh/zshrc
.vim ->.config/vim
.vimrc -> .config/vim/vimrc
and so on...
I got a branch for work and a branch for home for each repo, and everything is fine.
Offline
- Some put the files in ~/dotfiles/* and symlink them, often using a script. This sounds rather complicated to me.
This can in fact work quite well.
Currently, I got git repos in
.config/vim, .config/zsh and .config/awesomewith some symlinks:
.zshrc -> .config/zsh/zshrc
.vim ->.config/vim
.vimrc -> .config/vim/vimrcand so on...
I got a branch for work and a branch for home for each repo, and everything is fine.
I have the same style set up. It makes everything much easier.
.emacs -> ~/configs/emacs
And emacs git mode makes it easier as well ...
Offline
I tried both gibak and git-home-history but for me they were more trouble then help so I went with a simple git repository in my home directory.
At first I had a remote branch for each computer but after some merging this got messy. Now I have a single remote branch with a local branch on each computer for computer specific customizations. I commit changes to my config files on the master branch which gets pushed to a remote repository. The local branches are updated by rebasing them to the master branch. So far this worked ok for me.
I also have a rather extensive .gitignore file deciding which files are synched by git.
Offline
I just run a git repo directly in ~, and just add the files I want to it, instead of doing git add .
Evil #archlinux@libera.chat channel op and general support dude.
. files on github, Screenshots, Random pics and the rest
Offline
Thanks for all the input! I think I'll try to put all dotfiles in a separate directory and hardlink.
Those of you who do it this way, do you have a script (preferable bash) or do you run ln 'manually'?
Offline
I just do 'git add .' 'git commit -a' and 'git push'. Manually
Offline
Hi
I'm playing around with git to manage my dotfiles. I set up a bare repo on my NAS and a local repository under ~/. I added the remote repo to the local one so I can push and pull. This works for files like .bashrc because it is stored under ~/. Now I want to hard link files like rc.conf and others stored under /etc. When I try to create a hardlink I get an error "invalid link across devices" because /home and / are on seperated partitions. So is it a good idea to softlink those files (ln -s)? Will this work, too?
Another question:
How could I restore all files if I lost them/set up a new machine? First thing would be to clone the repo from the server and then? I would have the ~/dotfiles/ repo will all files in it, do I have to manually cp the files in this directory to where they belong to (cp ~/dotfiles/rc.conf /etc/rc.conf and so on..)?
Thanks for answering my noob questions.
Offline
Guess I should update this topic with the solution I arrived at:
I have a ~/.dotfiles directory now and create softlinks in ~ (e.g. ~/.bashrc -> ~/.dotfiles/bashrc, ~/.vim -> ~/.dotfiles/vim). To create the symlinks I use the following script:
#!/bin/bash
DIR=/home/hans/.dotfiles/
mkdir -p ~/dotfiles_old
cd $DIR
for i in *
do
mv ~/.$i ~/dotfiles_old/
ln -s $DIR/$i ~/.$i
done
rm ~/.make.sh
Not very beautiful but it works. (It's in ~/.dotfiles/, if you wonder what the last line is for).
The master branch contains common configuration for all computers. Each computer has a local branch to handle local customizations. When I want a change to apply globally, I checkout master or use cherry-pick, and finally rebase the local branch.
Offline
I use this script to copy files that have changed into ~/dotfiles. For every file and directory in ~/dotfiles it checks if a .<name> exists in home, then compares and makes a copy. Main repo is on my workstation, every other machine has a branch with local changes. Workstation also has a public branch stripped of all sensitive data, so I can share my dotfiles with others.
Last edited by anrxc (2009-11-13 16:41:49)
You need to install an RTFM interface.
Offline
Ehm, now I am confused.:D
Why are those scripts necessary? If I create a softlink, lets say
ln -s /etc/rc.conf ~/dotfiles/rc.conf
why do I need to run the script? The name of the file will not change, so why is it necessary to create the link again?
Offline
It's not - the script is for the first time I set it up. Just a little convenient thing.
Offline
Ah ok, thought you run this everytime you change something.:rolleyes:
Thanks for your answers, folks.;)
Offline
Mhh, problems.
I did the following in my ~/, ~/dotfiles is the folder where the git repo is placed:
echo 'testtesttest'> testfile
ln -s ~/testfile ~/dotfiles/testfile
cd dotfiles/
git status
worked like expected:
git status
# On branch master
# Your branch is ahead of 'origin/master' by 6 commits.
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# testfile
nothing added to commit but untracked files present (use "git add" to track)
then
git add .
git status
# On branch master
# Your branch is ahead of 'origin/master' by 6 commits.
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: testfile
#
git commit -m 'testfile'
[master 818fefe] testfile
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 120000 testfile
Ok, now for the problem.:D
cd ~/
nano testfile (modifying the testfile)
cd dotfiles/
git status
# On branch master
# Your branch is ahead of 'origin/master' by 7 commits.
#
nothing to commit (working directory clean)
I modified the testfile but git is not recognizing it?
I don't get it, also a 'git add .' did nothing. Why isn't git aware that I changed the testfile?
Thanks for help.
Offline
I think you should do it the other way around - real files in ~/dotfiles (git repo) and symlinks in ~. For example, ~/.bashrc -> ~/dotfiles/bashrc.
Offline
Mhh, that's not really what I want. If I don't want to use the git repo anymore I delete ~/dotfiles and everything is gone. If I do it the other way round this is not possible..:/
Now I have a central folder with symlinks. Otherwise there would be a bunch of files in it and symlinks spread all over the filesystem.
Last edited by Urfaust (2009-11-15 10:25:36)
Offline
Hm. In that case, have you tried hardlinks?
Offline
Hm. In that case, have you tried hardlinks?
Yes, see Posting #11. But
This works for files like .bashrc because it is stored under ~/. Now I want to hard link files like rc.conf and others stored under /etc. When I try to create a hardlink I get an error "invalid link across devices" because /home and / are on seperated partitions. So is it a good idea to softlink those files (ln -s)? Will this work, too?
This seems to be a doom loop.;)
Offline
Ah, sorry. I had read that, but forgot about it. Then I don't know any other solutions (other than doing the other way around).
Offline
Ok, but thanks for your answers.:)
Offline
@OP: you can also change your $HOME variable to /home/yourname/dotfiles, so you can avoid symlinking. This was proposed here for other reasons but I found out it worked nice for dotfiles versioning as well
EDIT: sorry for necrobumping, I read the post's date wrong...
Last edited by tzervo (2010-06-24 17:57:25)
Offline
Pages: 1