You are not logged in.
The Wiki suggests to use version control system to manage dotfiles. It provides an example on how to setup a Git repository inside the home directory. Unfortunately, there is no example on how to clone such a repository into the home directory. I found a post on stackoverflow that shows how to clone a Git repository into a non-empty directory.
git init
git remote add origin <url>
git fetch
git reset origin/master
git checkout -t origin/masterIf I follow these instructions I am getting the following error message after running the last command:
fatal: A branch named 'master' already exists.I came up with the following procedure which seems to work.
git init
echo '*' > .git/info/exclude
git remote add origin <url>
git fetch
git reset origin/master
git checkout master
# change, stage and commit some repo content
git push -u origin masterI am wondering if this is safe and/or if there is a better solution.
Last edited by hakunamatata (2018-06-22 08:37:51)
Offline
That should be fine, but if you are just starting to version your own dotfiles, then you shouldn't need to clone and pull a remote repository. If you have an existing dotfiles directory, then I assume you want to overwrite the current versions with your tracked versions, in which case what is your question about safety? ![]()
And this is interestingly coincidental, as I finally wrote my own control script because I haven't seen any solutions that I like. I don't want a symlink farm, as most methods seem to use -- I want to directly track my files in git, but using $HOME as a git repository is both messy (in terms of metadata, gitignore, README.md) and slightly dangerous in the sense that git commands will always treat $HOME as a top-level repository when you don't intend it to.
I've come up with a fairly simple rough wrapper around $GIT_DIR: https://github.com/eli-schwartz/dotfiles.sh
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline
Actually, I am already using version control for my dotfiles. But as you say, I am not too happy with my current approach - that relies on symbolic links.
By "safe" I mean that I don't want Git to accidently remove files from my $HOME directory - because of git-clean or similar.
Thank you for sharing your wrapper, it looks interesting and I look forward to investigate it further.
Offline
I'm not too worried about git-clean since clean.requireForce defaults to true. But certainly, adding * to your gitignore will prevent git-clean from deleting any files... unless you use `git clean -ix` which both forces the issue and ignores the gitignore. So really, there are always ways to get around this. I advise just not using git-clean. At all. ![]()
Managing AUR repos The Right Way -- aurpublish (now a standalone tool)
Offline