This is one way to go about it, although not so clean it does the job without the hassle of maintaining symlinks on each machine:
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
One thing you got to be careful is when you're cloning this repo on another machine, git clone
will error if the destination directory is not empty. So you could do something like this to initially set it up:
mkdir -p ~/temp-git-dir
cd ~
git clone <REPO-URL> ~/temp-git-dir
mv ~/temp-git-dir/.git .
rm -rf ~/temp-git-dir