Technical Diary of a Dummy

Thoughts and Opinions that will live on after they have vacated my brain.

DaC(Desktop as Code) -

James Land - 01 Feb 2021

DaC Desktop as Code

Eventually we all have to move on. Whether it is because you got a new laptop (YAY), or you had an sudden unexpected crash (less yay). And if you are you:

And regardless of how you lost some important file before I am sure that we have had to remember our little tips and tricks from our previous desktop setup. Which is why I have set up DaC (Desktop as Code) on my personal laptop.

It is very simple to do and can save you a ton of headache

Settup DaC

So first we need to create our git repository on GitHub, and remember you probably want to make this one private.

Then we set up our repository in our base directory

cd ~
git init

Now there is a good chance you are not looking to save every (or even most) file(s) in your base directory so lets create a .gitignore in the same directory as our repo to ignore all files.

Then we can just manually add the files we want to save to our git repository.

In the example below I have created the folder SaveToGitFolder where I can put any files I want to retain even if my laptop were to crash.

.gitignore

*


!.bashrc
!.gitignore
!Documents/importantFile.txt


!SaveToGitFolder
!SaveToGitFolder/*                   

Now if we run the following

git add --all
git status

We should see something similar to the following (assuming you created the SaveToGitFolder and importantFile.txt):

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)
	new file:   .bashrc
	new file:   .gitignore
	new file:   Documents/importantFile.txt
	new file:   SaveToGitFolder/Resume.odt

Now lets just checkin our files and you are done. Now note that you will have to make periodic checkins from time to time or this will not help. But next time your laptop crashes at least you will not lose everything!

Hope this helped

Tags:
desktop github favorite