dotfiles

feels like ${HOME}
Log | Files | Refs | README

README.md (2150B)


      1 # Git Setup Dotfiles
      2 
      3 ## Setting Up
      4 
      5 assuming you use Z Shell. If not, change `.zshrc` to your specific shell's config file (e.g `.bashrc` for Bash, or `config/fish/config.fish` for fish shell)
      6 
      7 ```sh
      8 git init --bare $HOME/.cfg
      9 alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
     10 config config --local status.showUntrackedFiles no
     11 echo "alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'" >> $HOME/.zshrc
     12 ```
     13 
     14 example commands:
     15 
     16 ```sh
     17 config status
     18 config add .vimrc
     19 config commit -m "feat: update .vimrc"
     20 config push
     21 ```
     22 
     23 
     24 ## Importing
     25 
     26 on a new system you can migrate to this setup. Prior installation, make sure you have committed the alias to your shell config file:
     27 
     28 ```sh
     29 alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
     30 ```
     31 
     32 And that your source repository ignores the folder where you'll clone it, so that you don't create weird recursion problems:
     33 
     34 ```sh
     35 echo ".cfg" >> .gitignore
     36 ```
     37 
     38 Now clone your dotfiles into a bare repository in a "dot" folder of your `$HOME`:
     39 
     40 ```sh
     41 git clone --bare <git-repo-url> $HOME/.cfg
     42 ```
     43 
     44 Define the alias in the current shell scope:
     45 
     46 ```sh
     47 alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
     48 ```
     49 
     50 Checkout the actual content from the bare repository to your `${HOME}`:
     51 
     52 ```sh
     53 config checkout
     54 ```
     55 
     56 
     57 The step above might fail with a message like:
     58 
     59 ```sh
     60 error: The following untracked working tree files would be overwritten by checkout:
     61     .bashrc
     62     .gitignore
     63 Please move or remove them before you can switch branches.
     64 Aborting
     65 ```
     66 
     67 This is because your `$HOME` folder might already have some stock configuration files which would be overwritten by Git. The solution is simple, back up the files if you care about them, remove them if you don't care. I provide you with a possible rough shortcut to move all the offending files automatically to a backup folder:
     68 
     69 ```sh
     70 mkdir -p .config-backup && \
     71 config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | \
     72 xargs -I{} mv {} .config-backup/{}
     73 ```
     74 
     75 Rerun the init:
     76 
     77 ```sh
     78 config checkout
     79 config config --local status.showUntrackedFiles no
     80 ```
     81 
     82 Now, you're ready to come `${HOME}`  🏠