Comments (5)
- git clone --bare https://github.com/collegeimprovements/dotfiles $HOME/.dotfiles
- dot checkout
- dot config --local status.showUntrackedFiles no
from dotfiles_old.
Manage Dotfiles With a Bare Git Repository
Sep 18, 2016
After switching from Sublime Text to vim, I started looking for a way to manage my dotfiles. It took me a lot of work to configure and understand them, so I wanted to back them up against emergency. And of course I wanted to have those personal settings wherever I work.
At first I considered Vagrant, but it seemed like an overkill for just a few dotfiles. My next idea was to symlink dotfiles to a single directory and manage that folder with git. But that also felt unnecessarily complex - surely there would be a simpler way to do this, right?
And then I found what I was looking for. This method uses a git bare repository, and aliasing git commands to send them to that repo. Simple setup process? Check. Version control in git? Check. Easy installation on different machine? Check. Awesome!
Setup
Git is the only dependency. The following four lines will set up the bare repository.
git init --bare $HOME/.dotfiles.git
echo 'alias dotfiles="/usr/bin/git --git-dir=$HOME/.dotfiles.git/ --work-tree=$HOME"' >> $HOME/.zshrc
source ~/.zshrc
dotfiles config --local status.showUntrackedFiles no
Create a git bare repository at ~/.dotfiles.git to track files.
Add alias setting to shell configuration file. I use zsh so it’s .zshrc. For bash, it’d be .bashrc. Note how the paths for git directory and working tree are set.
Reload the shell setting.
Prevent untracked files from showing up when we call dotfiles status.
That finishes the setup. Use the aliased command from the home directory to manage files, and use git remote repo if you want to manage the files online.
dotfiles status
dotfiles add .vimrc
dotfiles commit -m "Add vimrc"
dotfiles remote add origin https://www.github.com/username/repo.git
dotfiles push origin master
Installing dotfiles to another system
It just needs two shell commands before fetching the remote repo.
echo 'alias dotfiles="/usr/bin/git --git-dir=$HOME/.dotfiles.git/ --work-tree=$HOME"' >> $HOME/.zshrc
source ~/.zshrc
echo ".dotfiles.git" >> .gitignore
git clone --bare https://www.github.com/username/repo.git $HOME/.dotfiles.git
dotfiles checkout
dotfiles config --local status.showUntrackedFiles no
Create alias to ensure that the git bare repository works without problem.
Reload the shell setting to use that alias.
Add .dotfiles.git directory to .gitignore to prevent recursion issues.
Clone the repo.
Check if it works fine.
If you already have configuration files with identical names, checkout will fail. Back up and remove those files. Skip back up if you don’t need them.
Prevent untracked files from showing up on dotfiles status.
That’s about it! Credit goes to anonymous giants in the Internet for coming up with this, and Nicola Paolucci for elegantly documenting the steps. Here’s the link to his original post.
from dotfiles_old.
Instead of dotfile
we alias it to dot
command.
from dotfiles_old.
https://www.howtogeek.com/700398/how-to-automatically-hide-or-show-the-menu-bar-on-a-mac/
Hide menubar on desktop to use the full screen without going to fullscreen mode(cmd+ctrl+f).
from dotfiles_old.
copy dot
command from .zshrc file.
from dotfiles_old.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dotfiles_old.