Hacker News new | ask | show | jobs
by nerdponx 1258 days ago

  # Save the repo to `~/.dotfiles`; the `--bare` option prevents Git from making
  # a mess of your home directory.
  git clone --bare ... ~/.dotfiles

  # Set up an alias for this shell session (it's also in ~/.config/aliasrc).
  alias dots='git --git-dir=$HOME/.dotfiles --work-tree=$HOME'

  # Make sure we don't show untracked files in `git status` output.
  dots config --local status.showUntrackedFiles no

  # Checkout all local files.
  # NOTE: This might overwrite existing files, or you might need to stash files
  # before proceeding. Look before you leap. If you have an existing setup,
  # consider checking out individual files as needed and testing the
  # configuration piecemeal, instead of doing a complete checkout.
  dots checkout

  # Make sure we can access remotes properly. The `--bare` option requires us to
  # do this manually.
  dots config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"

  # Make sure we are set up to track the remote `master` branch. Again, this is a
  # consequence of cloning with `--bare`.
  dots branch --set-upstream-to=origin/master master
  dots switch master

  # Fetch to make sure everything is configured correctly.
  dots fetch origin