I'd like to create one single git repo in my Linux $HOME directory. In this repo - obviously - I could add everything under version control, but this wouldn't make any sense. I'd like to only add the files and folders that are relevant to me, like .vimrc, .vim, .bashrc, etc. (probably only hidden files and folders, but maybe not)
I know I could leverage .gitignore to try and achieve such behavior but that would be painful and virtually un-maintainable. Instead, what I'd want to know is if there'd be any way to manually declare files and folders that I would want to manage, and only that.
By default Git wants to use your user directory as its home directory. This is where it wants to put all its configuration files and repositories; it is the default location that is opened when you start Git Bash.
Browse to the desired Directory through Commands in Git Bash Open your Git Bash. Type the following command cd <path of the directory> and press enter.
All of the local git "stuff" is placed in the . git folder in your "local repos" a.k.a. "working folder/directory". Folder/directory here is a folder that can contain other folders/directories - as well as files - indeed it will always contain a . git folder, otherwise it would not be a repository.
.gitignore
# Ignore everything * # But not these files... !*.vimrc !*.vim !*.bashrc !.gitignore # etc...
My home directory is also on GitHub.
I would setup an alias for use only with your home repo this way you can use the alias in place of git command and you always know the context you are working in
# .bashrc alias home='git --work-tree=$HOME --git-dir=$HOME/.home'
Issuing the comand
$ home init
will create a repo in .home folder in your $HOME and irrelevant of current directory you can work with your home repo with the alias 'home' in place of 'git'
This alongside a .gitignore should be all you need.
# .gitignore * # keep track !.bashrc !.gitignore
NB. DO NOT KEEP .ssh/keys in repo as it presents file permission and security issues.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With