I have seen a few people that have git repos with their dot files. I'm wondering if they just
cd ~/ git init git add .vimrc // etc
? And then that's how they keep it up to date? Or do they probably make copies and sync them?
What strategy do you guys recommend or use? Mostly don't wanna commit and push my entire ~/
Thanks
The global or system-wide vim configuration file is generally located under the /etc/vim/vimrc . This configuration file is applied to all users and when Vim is started this configuration file is read and Vim is configured according to this file contents.
To create dotfiles, you use the touch command and pass the name(s) of the file(s) as the argument to the command. The filename(s) will have a preceding period. The first argument is the current path of the file – the tilde ( ~ ) stands for the home direcory.
Making a git repository of your home is probably a bad idea (you would be spending more time creating your .gitignore file than on doing what you really want to do).
I suggest using a separate git directory for your dotfiles (eg. ~/git/dotfiles
) and them making symlinks to your home (eg. ln -s ~/git/dotfiles/.vim ~/.vim
, etc.).
If you can't be bothered creating symlinks manually each time you want to install your dotfiles somewhere, you can use a script like the following one: https://github.com/gibfahn/dot/blob/master/link.
I have my ~/.vim
directory under version control and my "real" vimrc
(the one with all my settings) inside that directory, at ~/.vim/vimrc
:
~/ ---- .vim/ ---- ---- (plugins and stuff) ---- ---- vimrc ---- .vimrc
My regular ~/.vimrc
has only one line:
runtime vimrc
No need to create symlinks or whatever.
This is how I would push my config on a new machine where Git has already been installed:
$ cd $ git clone [email protected]:romainl/dotvim.git .vim $ echo "runtime vimrc" > .vimrc
What follows is the whole creation process. I assume that you have created an account and a repo named "vimconfig" on Github and that you already have a lovingly crafted ~/.vimrc
and a well organized ~/.vim/
.
$ cd $ mv .vimrc .vim/vimrc $ echo "runtime vimrc" > .vimrc $ cd .vim $ git init $ echo "This is my Vim config." > README $ git add * $ git commit -m "My Vim config is versioned." $ git remote add origin https://github.com/username/vimconfig.git $ git push origin master
At that point, you should have the same content on Github and in your local repository.
You manage that repository normally and push your commits when you are ready. Simple.
Note that the whole Github thing is only useful if you need/want to sync your config on multiple machines or, somehow need/want to share it with others. If you don't, there's no real point using GitHub at all.
(edit)
Vim 7.4 introduced a new, very useful, scheme: it looks for the usual ~/.vimrc
and also for ~/.vim/vimrc
so that's even less work for you:
$ cd .vim $ git init $ echo "This is my Vim config." > README $ git add * $ git commit -m "My Vim config is versioned." $ git remote add origin https://github.com/username/vimconfig.git $ git push origin master
Of course, the strategy I suggested initially is still valid if you have to deal with mixed Vim versions: Vim knows what to do and won't crap out in an endless loop.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With