Step 1: Create a repository at github
Log into your account at github (if you don't have one, create one), and click on "Create a new repo". There you should enter a good name for your repository (I suggest "dotfiles" or similar) and - if you want - a description. Then click on "create repository". Done ;)In case you haven't done so already, you should add the public SSH keys of your machines to the list of authorized keys, otherwise you won't be able to commit to your git repositories using SSH.
(In short, you have to copy the contents of
~/.ssh/id_dsa.pub
into the box at the github site. If you have no idea what I'm talking about, better read up on SSH public key authentication.)Step 2: Initialize the dotfiles directory and repository
At first, you need to create the.dotfiles
directory and move the dotfiles that you want to put under revision control there.mkdir ~/.dotfiles mv ~/.bashrc ~/.dotfiles/bashrc mv ~/.bash_aliases ~/.dotfiles/bash_aliases mv ~/.screenrc ~/.dotfiles/screenrc mv ~/.vimrc ~/.dotfiles/vimrcThen you need to place the symlinker script there, make it executable and execute it.
cd ~/.dotfiles chmod u+x symlinks.sh ./symlinks.sh
Then initialize your repository and link it to github. This only needs to be done once.
git init git config --global user.name "YOUR NAME" git config --global user.email yourmail@something.com git remote add origin git@github.com:where "YOUR NAME" and yourmail@something.com are the name and mail address with which your commits will be signed. You don't have to do this and you don't have to provide your real name or address there. Decide for yourself./dotfiles.git
But GITUB_USERNAME has to be your github username (who would have guessed ...).
Step 3: Track changes with git
Now and whenever you have changed something in your.dotfiles
folder, add those changes or files to the repository and push it to github.git add bashrc git add bash_aliases git add screenrc git add vimrc git add symlinks.sh git commit -m "First commit with some rc-files and symlinks.sh" git push origin master
Step 4: Add additional machines to your dotfiles management
Whenever you want to place another machine under your git dotfile management, you need to check out that repository on that machine.mkdir ~/.dotfiles git clone git@github.com/dotfiles.git ~/.dotfiles git config --global user.name "YOUR NAME" git config --global user.email yourmail@something.com
Step 5: Pull changes from your github repository to your local machine
I haven't thought about whether I want to automate this step and how. For the moment, manually pulling changes from github seems the best solution to me, since I'm not changing my dotfiles on a daily basis.git pull origin masterand sometimes
~/dotfiles/symlinks.shif you just added the machine to the management system or if new dotfiles have been put under revision control.
Addtional remarks
I've found it to be more comfortable to github as upstream repository withgit push -u origin masterbecause after that I only have to use
git pushand
git pull
Also, I wrote this article bases on the bash histories of my machines, so in case you encounter an error, please tell me so in the comments so that I can correct this article. Thanks ;)
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.