Skip to content
/ dotfile Public

This Git repository stores the configuration files for my personal computer

License

Notifications You must be signed in to change notification settings

Xunop/dotfile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

dotfile

This Git repository stores the configuration files for my personal computer.

Referenced from this article: How to Store Dotfiles - A Bare Git Repository | Atlassian Git Tutorial

Usage

Install dotfile from repo

  1. Create an alias for the Git repository using the config command:
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'
  1. Add .cfg folder to .gitignore
echo ".cfg" >> .gitignore
  1. Clone repo:
git clone --bare <git-repo-url> $HOME/.cfg
  1. Checkout the actual content from the bare repository to your $HOME:
config checkout

if you fail with a message like:

error: The following untracked working tree files would be overwritten by checkout:
    .bashrc
    .gitignore
Please move or remove them before you can switch branches.
Aborting

This is because your $HOME folder might already have some stock configuration files which would be overwritten by Git. I alaways delete those files.

According to that article you can save these file like this:

mkdir -p .config-backup && \
config checkout 2>&1 | egrep "\s+\." | awk {'print $1'} | \
xargs -I{} mv {} .config-backup/{}

rerun config chekout

Don't forget to enter the following command, this command tells Git not to display status informantions for untracked files (i.e., files that are not under version control). the --local parameter indicates that this configuration is only valid for the current repository.

config config --local status.showUntrackedFiles no

Tracking your configurations in a Git repository

  1. Initialize the Git repository:
git init --bare $HOME/.cfg
  1. Create an alias for the Git repository using the config command:
alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'

You can use this command to add an alias to the user's .bashrc/.zshrc file so that it can be used every time you start the terminal:

echo "alias config='/usr/bin/git --git-dir=$HOME/.cfg/ --work-tree=$HOME'" >> $HOME/.zshrc
  1. Configure Git to ignore untracked files:
config config --local status.showUntrackedFiles no
  1. Add your configuration files to the Git repository:
config add <file>
config commit -m "<commit message>"
  1. Push your changes to a remote repository:
config push <remote> <branch>

About

This Git repository stores the configuration files for my personal computer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published