Skip to content

Instantly share code, notes, and snippets.

@murar8
Last active February 5, 2022 12:27
Show Gist options
  • Save murar8/1692ea7c396e6beb1030c382d71e6f84 to your computer and use it in GitHub Desktop.
Save murar8/1692ea7c396e6beb1030c382d71e6f84 to your computer and use it in GitHub Desktop.
Initialize dotfiles repository.
#!/usr/bin/env bash
REPO_URL=git@github.com:murar8/dotfiles.git
REPO_DIR=$HOME/.dotfiles
echo "Starting bootstrap procedure."
set -e
if ! command -v git >/dev/null; then
echo "Error: could not locate git in your path."
exit 1
fi
if [ -d $REPO_DIR ]; then
echo "Error: it looks like the $REPO_DIR folder is already present."
exit 1
fi
dot() {
git --git-dir=$REPO_DIR/ --work-tree=$HOME $@
}
echo "Creating bare repository in $REPO_DIR."
git init --bare $REPO_DIR
dot config status.showUntrackedFiles no
dot remote add origin $REPO_URL
echo "Pulling files from upstream."
dot fetch --all
dot reset --hard origin/master
echo "Bootstrap procedure completed successfully."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment