dotfileをgithubで管理する
dotfileをgithubで管理したくなったのでその流れです。
まずは公開鍵を作成するということで
ssh-keygen cd ~/.ssh sudo chmod 600 id_rsa.pub
ssh接続時に秘密鍵を使うための設定を.ssh/configファイルに以下を書き込みます。
sudo vim config
Host github.com Hostname github.com Identityfile ~/.ssh/github/id_rsa
公開鍵の内容をgithubのサイトから登録します。Account SettingsのSSH public Keysに登録します。
gitで接続します。
ssh git@github.com
Webの方にディレクトリを作成したら表示されたコマンドを実行します。
git config --global user.name "USERNAME"
git config --global user.email USERNAME@***
USERNAMEはユーザ名、USERNAME@***はメールアドレスです。
必要なファイルをコピーします。
cd ~
mkdir dotfiles
mv .vimrc dotfiles
mv .gvimrc dotfiles
mv .zsh_profile dotfiles
mv .vim dotfiles
mv .tmux.conf dotfiles
cd dotfiles git init git add . git commit -m "first commit"
git initでリポジトリを初期化、git add .でディレクトリ内のすべてのファイルをaddしてコミットする。この時点ではまだローカル環境にコミットしただけです。
エラーがいくつかでました。
Not a git repositoryというエラーが出た場合は.gitのファイルを削除したら通りました。
git remote add origin git@github.com:USERNAME/dotfiles.git
githubのリポジトリをoriginという名前で登録します。
git push -u origin master
これでgithubにpushされました。
参考:
http://shim0mura.hatenadiary.jp/entry/20111212/1323660740
http://tkr.hatenablog.com/entry/2013/08/08/011855
http://dev.classmethod.jp/etc/github-homesick-dotfiles/