Giter VIP home page Giter VIP logo

dotfiles's Introduction

Bare Git Repo

Install on a New Machine

git clone --separate-git-dir=$HOME/.dotfiles.git https://github.com/allpan3/dotfiles.git dotfiles-tmp
rsync --recursive --verbose --exclude '.git' dotfiles-tmp/ $HOME/
rm -rf dotfiles-tmp
git --git-dir=$HOME/.dotfiles.git --work-tree=$HOME config status.showUntrackedFiles no

Next, checkout the system-specific branch that you would like to install.

git --git-dir=$HOME/.dotfiles.git --work-tree=$HOME checkout <branch>

If this is a new type of machine to set up, create a new branch for it.

git --git-dir=$HOME/.dotfiles.git --work-tree=$HOME checkout -b <branch>

Start a new shell to allow settings to take effect. Use git dot for any git commands targeted for this bare metal (alias set in shell configuration).

Branch Organization

Branches are organized in the following fashion: master branch contains all base files that are shared among all systems. Each system, if necessary, has its own branch where system-specific files plus all files from master are stored. Multiple systems can share one system-specific branch if that's sufficient.

Shared files should be committed in the master branch. In system-specific branches, sync in the changes in master by running dgit rebase master. If shared files are accidentally added and committed in a system-specific branch, use dgit cherry-pick to migrate them to the master branch.

One minor issue with this method is, after switching from system-specific branches to master branch, the files which are only tracked in system-specific branches will be removed from the working tree. This may cause trouble if you perform certain activities in the master branch. Therefore, it is recommended to stay in system-specific branches for most of the work, and only switch to master branch when you commit the changes.

Manage Multiple Systems

There are a few ways to manage system-specific settings. Not all of them are available for a given configuration context. Here are some methods that work in conjunction with the branch organization, listed in the order of ease to sync. It is the best to apply the first-ever possible rule.

  1. Use condition statements based on $(uname) or $(hostname) to separate out system-specific settings within the same configuration file.

  2. Create system-specific "sub-files", conventionally named "xxx_local" to store system-specific settings, and include/source them in the main configuration files. Store these local files in system-specific branches.

  3. Having separate versions of a configuration file and store each in a different system-specific branch.

    • There can still be a base version of the file stored in master for any systems without special settings to use, as well as storing the common part to allow syncing through rebasing. But, must be careful that there's no conflict with the system-specific versions, otherwise conflict-resolving will be required every time you do dgit rebase.
    • If no base version is stored in master branch, must remember to add any common changes in all of the branches. This creates extra hassle in the syncing process.

Pull from Repo

dgit pull origin --rebase

dotfiles's People

Contributors

allpan3 avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.