As some of you already know, this blog is generated by jekyll, wich I run directly on my Linode VPS. I ssh my server, use vim to write my posts, and then generate the blog with jekyll, but sometimes I want to write while not connected, I use rsync to backup my entire blog to my Macbook Pro, and to my Arch Linux Desktop.
Today I studied a little about git, and read some manuals, and after learning a little about it, I have seen that it could be a good option to keep my blog in sync with the three computers I have: My server, my Desktop and my laptop.
What I have done is:
- Created the git repository in the server
- Cloned the repository to the Desktop, laptop and the server itself.
Now I have the same info everywhere, with a version control, (yes rsync can do that too, but I like to learn new things)
Here is how I finally did it.
I will assume you have already know how to install git in your current operating system
- Create the Master Repository in the Server
I have done this in my main server (the VPS) which is powered by Gentoo.
mkdir ~/my-git-master cd my-git-master git -bare init
Now the repository is created.
Clone the repo, in the same machine, in case I would like to work via ssh
mkdir ~/my-synced-folder cd ~/my-synced-folder git clone ~/my-git-master
Clone the repo, in the remote computer.
mkdir ~/my-synced-folder cd ~/my-synced-folder git clone ssh://firstname.lastname@example.org/~/my-git-master
OK, now I just only need to add some content to any of sides, let's say the remote computer
cd ~/my-synced-folder/my-git-master echo "This is a test" > test.txt git add -A git commit -a
Add your comment in the file that will automatically be opened.
git push origin master
Now, when you want to continue your work in the other computer.
cd ~/my-synced-folder/my-git-master git pull
Et voila!, you know have the same content in both computers, and you can have a third or fourth, just remember that whenever you change something, you need to run:
git add -A git commit -a git push origin master
And on the computer you want to star working later, always run, before starting:
This is not intended to be a complete guide, just a guide, for you to start working with git.