Adding your .vim ~ / .vimrc to github (aka dot files)

I saw several people who have git repos with their dot files. I wonder if they are just

cd ~/ git init git add .vimrc // etc 

? And then, how are they constantly updated? Or are they likely to make copies and synchronize them?

What strategy do you recommend or use? Basically I do not want to commit and press all my ~ /

thank

+53
git vim dotfiles
Aug 12 '13 at 10:28
source share
5 answers

Creating a git repository for your home is probably a bad idea (you would spend more time creating a .gitignore file than what you really want to do).

I suggest using a separate git directory for your point files (e.g. ~/git/dotfiles ) and make symbolic links to your home from them (e.g. ln -s ~/git/dotfiles/.vim ~/.vim , etc. .).

If you are not worried about manually creating symbolic links each time you want to install your point files somewhere, you can use a script similar to the following: https://github.com/gibfahn/dot/blob/master/link .

+71
Aug 12 '13 at 22:38
source share

I have a ~/.vim under version control and my "real" vimrc (the one with all my settings) inside this directory, ~/.vim/vimrc :

 ~/ ---- .vim/ ---- ---- (plugins and stuff) ---- ---- vimrc ---- .vimrc 

My regular ~/.vimrc has only one line:

 runtime vimrc 

No need to create symbolic links or anything else.

Here's how I would push my configuration on a new computer where Git is already installed:

 $ cd $ git clone git@github.com:romainl/dotvim.git .vim $ echo "runtime vimrc" > .vimrc 

The following is the entire creation process. I assume that you have created an account and repo named vimconfig on Github and that you already have a lovingly created ~/.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 this point, you should have the same content on Github and in your local repository.

Usually you manage this repository and push your commits when you are ready. Plain.

Please note that all Github work is useful only when you need / need to synchronize your configuration on several computers or somehow need / want to share it with others. If you do not, there is no real point on GitHub.

(edit)

Vim 7.4 introduced a new, very useful scheme: it is looking for the usual ~/.vimrc , as well as for ~/.vim/vimrc , to work even less 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 proposed is still valid if you have to deal with mixed versions of Vim: Vim knows what to do and will not crash in an endless loop.

+50
Aug 13 '13 at 7:53 on
source share

I already have a โ€œbundleโ€ folder into which I upload all my plugins via Pathogen . So I created this folder in my git folder (with plugins as submodules) and placed vimrc there.

In the official .vimrc I write:

 let $MYVIMRC="<path_to_vimrc_in_bundle_folder>" source $MYVIMRC ... call pathogen#infect() 

and I'm not the version of it!

This allows me to share my configuration between my Linux machine at home and my Windows operating system. I can also specify official .vimrc configurations specific to the machine, or those that I do not want to publish (for example, dbext profiles containing logins and passwords ...)

+4
Aug 13 '13 at 8:56
source share

Here is an agnostic and agnostic solution to the platform without any dependencies, in addition, you have a bourne compatible shell (bash, zsh, ksh, etc.). It works on mac, linux and windows:

dotsys

It automatically syncs changes to your dotfiles with github and multiple machines along with many other features.

+1
Aug 06 '16 at 15:44
source share

Check out StreakyCobra's solution at Hacker News :

 git init --bare $HOME/.myconf alias config='/usr/bin/git --git-dir=$HOME/.myconf/ --work-tree=$HOME' config config status.showUntrackedFiles no 

where ~/.myconf is the location of the empty git repository. Then any files in $HOME can be versioned as follows:

 config status config add .vimrc config commit -m "Add vimrc" config add .config/redshift.conf config commit -m "Add redshift config" config push 

If you need further explanation, Nikola Paolucci has provided an excellent explanation .

+1
Mar 04 '17 at 18:43 on
source share



All Articles