The procedure listed below is the method which worked for me to backup my dotfiles to my self hosted git server. It is not perfect. Meets my requirements.
On your Desktop
$ mkdir dotfiles.git (It is a norm to name the repository as reponame.git if a bare git repository is to be built up)
$ cd dotfiles.git
Now we will create a git bare repository. The git bare repo will not have a hidden .git folder.
$ git init --bare
Since the repository is bare, you have to populate it. So whenever we run a git command, the command should have the following info.
git --git-dir=$HOME/all_gits/dotfiles.git --work-tree=$HOME (Do not run this command now)
with the above line we have now indicated that the work tree is the complete home directory. The above line will be used repeatedly. Create an alias for the command above in .bashrc
alias gitdotfiles="git --git-dir=$HOME/all_gits/dotfiles.git --work-tree=$HOME"
Now let us update configuration for this git repository to not bother us about the un-tracked files in the work tree since there are lots of files in the home directory
$ gitdotfiles config --local status.UntrackedFiles no
Let us now start adding files to the git repository form the work tree
$ gitdotfiles add ~/.bashrc
$ gitdotfiles commit -m "added bashrc"
Let us now create a remote repository to push these files. These can then be pulled on to a new system where you want these files
$ gitdotfiles remote add origin username@IP_of_self_hosted_git_server:/path/to/dotfiles.git
On the self hosted git server
$ mkdir dotfiles.git
$ cd dotfiles.git
$ git init --bare
For the first time when you are going to push
$ gitdotfiles push --set-upstream origin master
Check the transaction on any client machine or on your desktop
$ mkdir delete
$ cd delete
$ git clone username@IP_of_self_hosted_git_server:/path/to/dotfiles.git
You should see the dotfiles directory.
$ cd dotfiles
$ ls -a (.bashrc is a hidden file)
Let us now further add files, back on your desktop
$ gitdotfiles add .config/i3/
$ gitdotfiles commit -m "added i3 config file"
$ gitdotfiles push origin master
To get a list of added/tracked files
$ git ls-files
That completes the initial setup. Further, as you make changes, you will have to check the changes made to the files you have added.
$ git status
The above command will return a huge list of files, scroll up to the beginning and there your will find the changes you have made to your added files/directory. Follow the procedure of adding, committing and pushing with the aliased gitdotfiles command.
No comments:
Post a Comment
Nobody can deter me away from "free as in freedom" concept seeded by Sri RMS. See to it that u dont make fun of my belief. If u think otherwise, no need to comment.