cd ~;
git init --bare ~/dotfiles;
echo 'alias bare="/usr/bin/git --git-dir=$HOME/dotfiles --work-tree=$HOME"' >> ~/.bashrc;
source ~/.bashrc;
bare config --local status.showUntrackedFiles no;
bare add ~/any_folder/any_file.sh;
bare status;
bare commit -m "Added some configs";
bare branch -M master; # Rename the current branch to "master"
bare remote add origin git@github.com:shreewatsa/dotfiles.git;
bare push -u origin master;
echo "dotfiles" >> .gitignore;
echo 'alias bare="/usr/bin/git --git-dir=$HOME/dotfiles --work-tree=$HOME"' >> ~/.bashrc;
source ~/.bashrc;
bare config status.showUntrackedFiles no
git clone --bare git@github.com:shreewatsa/dotfiles.git $HOME/dotfiles;
bare checkout; # If conflict with existing files, either remove/rename/move those existing files.
You can automate above like this:
#!/bin/bash
git clone --bare git@github.com:shreewatsa/dotfiles.git $HOME/dotfiles;
function bare {
/usr/bin/git --git-dir=$HOME/dotfiles/ --work-tree=$HOME $@
}
bare checkout
if [ $? = 0 ]; then
else
mkdir -p .config-backup
bare checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | xargs -I{} mv {} .config-backup/{}
bare checkout
fi;
You can even create a gist of this snippet, then curl and run the snippet like this:
$curl -Lks <gist/snippet url> | /bin/bash;