Last active
January 6, 2024 11:29
-
-
Save pacharanero/1c2c4dcb1b7a6b015e2113fa4b734956 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -x | |
set -e | |
# COMMAND | |
# curl -Lks https://gist.github.com/pacharanero/1c2c4dcb1b7a6b015e2113fa4b734956/raw | /bin/bash | |
# add .dotfiles-git to global .gitignore to prevent it tracking itself recursively | |
echo ".dotfiles-git" >> .gitignore | |
# creates bare Git repo in a .hidden subdir of $HOME | |
git init --bare $HOME/.dotfiles-git | |
# adds that same 'dotfiles' alias to .zshrc for future uses | |
echo "alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles-git/ --work-tree=$HOME'" >> $HOME/.zshrc | |
# configures Git not to constantly remind us about the thousands of untracked files in $HOME | |
/usr/bin/git --git-dir=$HOME/.dotfiles-git/ --work-tree=$HOME config --local status.showUntrackedFiles no | |
# add GitHub remote | |
/usr/bin/git --git-dir=$HOME/.dotfiles-git/ --work-tree=$HOME remote add origin https://github.com/pacharanero/dotfiles.git | |
/usr/bin/git --git-dir=$HOME/.dotfiles-git/ --work-tree=$HOME checkout -b main | |
/usr/bin/git --git-dir=$HOME/.dotfiles-git/ --work-tree=$HOME branch --set-upstream-to=origin/main main | |
echo """You can now use the 'dotfiles' command instead of 'git' eg: | |
# to delete current .zshrc and overwrite with GitHub version | |
$ rm .zshrc; dotfiles pull origin main | |
# to save changes (in this example to .zshrc) to version control and push: | |
$ dotfiles add .zshrc | |
$ dotfiles commit -m "added .zshrc" | |
$ dotfiles push origin main | |
# (note that you will require push access credentials to push to the repo)""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment