我可以控制我的.bash_profile版本吗?

时间:2013-04-16 15:19:53

标签: git .bash-profile

在文件夹树中:

Hard_Disk:
- Applications
- Users:
- - User-1_folder
- - User-2_folder:
- - - - .bash_history
- - - - .bash_profile
- - - - .bashrc
- - - - .gitconfig
- - - - .gitignore_global
- - - - .ssh
- - - - Applications
- - - - Desktop
- - - - ...
- - User-3_folder
- Library
- System

我可以对我的.bash_profile或与.gitconfig相同的文件夹中的任何其他文件进行版本控制吗?

在User_folder中启动git存储库是否安全?

忽略所有文件夹和.gitconfig本身,只是为了保持一些设置正常运行!

1 个答案:

答案 0 :(得分:3)

这是一种方法,虽然不是那么干净,但没有在每台机器上维护符号链接的麻烦:

cd ~
git init

# Ignore everything except .bash_profile and .gitignore
echo '/*' > .gitignore
echo '!/.bash_profile' >> .gitignore
echo '!/.gitignore' >> .gitignore

# Only .bash_profile and .gitignore would be added
git add .

# Commit
git commit -m "Adding .bash_profile and .gitignore"

# Add the remote details and push the master branch into the remote
git remote add <REMOTE-NAME> <REMOTE-URL>
git push <REMOTE-NAME> master

要注意的一件事是当你在另一台机器上克隆这个仓库时,如果目标目录不为空,git clone将会出错。所以你可以做这样的事情来初步设置它:

mkdir -p ~/temp-git-dir
cd ~
git clone <REPO-URL> ~/temp-git-dir
mv ~/temp-git-dir/.git .
rm -rf ~/temp-git-dir