想在家里和公司两台 Mac 之间同步配置文件,搜到了这个解决方案:
The best way to store your dotfiles: A bare Git repository - Atlassian Developers
I use: git init --bare $HOME/.myconf alias config='/usr/bin/git --git-d... | Hacker News
别人写的中文介绍:使用 git 管理 dotfiles
主要用到的命令:
git init --bare $HOME/.myconf
alias config='/usr/bin/git --git-dir=$HOME/.myconf/ --work-tree=$HOME'
config config status.showUntrackedFiles no
#where my ~/.myconf directory is a git bare repository. Then any file within the home folder can be versioned with normal commands like:
config status
config add .vimrc
config commit -m "Add vimrc"
config add .config/redshift.conf
config commit -m "Add redshift config"
config push
方式略有点奇葩,不过好处是不用搞什么软链接。里面有一些 git 黑魔法,大家也可以学学
在我的理解里,git init --bare 一般是用于创建远程仓库的,它这里一开始创建的就是远程仓库
如果我也想把这个库同时 push 到 github 上去该怎么做?我想的是需要在电脑本地另外的位置 git clone 这个库,然后增加一个 github remote,应该就没有问题了