Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setup #3

Open
collegeimprovements opened this issue Apr 22, 2021 · 5 comments
Open

Setup #3

collegeimprovements opened this issue Apr 22, 2021 · 5 comments

Comments

@collegeimprovements
Copy link
Owner

Article: https://harfangk.github.io/2016/09/18/manage-dotfiles-with-a-git-bare-repository.html
git clone --bare https://github.com/collegeimprovements/dotfiles $HOME/.dotfiles

@collegeimprovements
Copy link
Owner Author

  1. git clone --bare https://github.com/collegeimprovements/dotfiles $HOME/.dotfiles
  2. dot checkout
  3. dot config --local status.showUntrackedFiles no

@collegeimprovements
Copy link
Owner Author

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.

@collegeimprovements
Copy link
Owner Author

Instead of dotfile we alias it to dot command.

@collegeimprovements
Copy link
Owner Author

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).

@collegeimprovements
Copy link
Owner Author

copy dot command from .zshrc file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant