Simple git bare repo guide (dotfiles)
1. Creation of the repo
git init --bare $HOME/.dot
- This creates the “git folder”, which only has git files, your dotfiles won’t be put in it. In this case I name it ".dotfiles" making it hidden on my home directory because of the period. You may change the location of the folder if you prefer, but if you do, remember to modify it accordingly on the next commands.
2. Shell aliases
If you don’t know about them learn them first, and also the concept of shells. The “dot” alias could be any word you want, “dot” is the alias name that I chose to do stuff with my git bare repo.
- Practical example: When I use the bare repo I type
dot add file
to add a file to the repo, I typedot commit message
to create a commit message anddot push
to push my changes to Gitlab/hub.
2.1 Create alias for bash:
alias dot='/usr/bin/git --git-dir=$HOME/$USER//.dot --work-tree=$HOME'
Remember: If you changed the git bare repo folder location you have to change it on the alias as well.
2.2 Create alias for fish
alias dot='/usr/bin/git --git-dir=$HOME/$USER//.dot --work-tree=/$HOME'
Remember: If you changed the git bare repo folder location you have to change it on the alias as well.
3. Configuration for your bare repo
This command is pretty much personal preference, what this command does is not taking into account the files that have not been added to the repo on your home directory, this serves to unclutter the dot status
aliased command.
dot config --local status.showUntrackedFiles no
If you don’t understand the purpose of it you can ignore it and come back later to it, no big deal.
4. How to use the git bare repo you just created
You did it!
If your aliased command is not called
dot
take that into account when running these commands and replace accordingly.
4.1 Adding files
dot add file.example
dot add -u
(for changes within previously added directories)
4.2 Committing the changes
dot commit -m "Name of commit"
4.3 Pushing the changes
dot push https://gitlab/hub.com/user/repo.git
4.3.1 Alternatively if you have ssh configured with gitlab/github/etc
- Which I highly recommend!
dot push