This article stems from me backing up this website via github using the git version control system. This helps always keep a back up of the site and files. This will also allow a rolling update of the site, all documented change by change. So just like any other version control system, this gives you the ability to roll back to any point in history if something were to go awry.
To begin with, you will need to have git installed on your system. This usually can be found via any package manager (ie. yum/apt-get/pacman). Feel free to poke your head on over to the official download site at git-scm.com. Once installed, I would recommend setting two variables right off the bat. This includes the email address and name that you want associated with git for pushing and pulling:
git config --global user.name 'John Doe'
git config --global user.email johndoe @ example.com
Once you have that set, now you can move on to creating a git repo and making changes. First, pick a directory and then run the following to initialize your repo:
Once that is done, git will track your changes from this point on in that directory. So go…go now and make some changes. Okay, now that you have done that, time to document what has changed. One thing to keep in mind that is that if you added any new files, you have to let git know about them. You will need the below command for each new file that was added to the directory during your change:
git add path/to/file
Alternatively, you could use:
git add .
but this sometimes leads to issues. Doing it this way will add everything in the directory, including anything in the child directories. This could and has been known to add files to your git repo that you never intended to be added. So I have found it to be better to just add the files as you code individually or at least, folder by folder instead of all the files at once.
Now that things have been edited/changed/added or whatever you have decided to do, it is now time to make the change official or ‘commit’ the change. To do this is pretty simple and can be done a couple of ways. This is the simplest way to do it all in one command without the need of an editor:
git commit -am "Put a message about your change"
This will commit all the changes to all the files that have changed since the last commit. Keep in mind if this is your first commit, this will So this article stems from me backing up this website via github using the git version control system. This helps always keep a back up of the site and files. This will also allow a rolling update of the site, all documented change by change. So just like any other version control system, this gives you the ability to roll back to any point in history if something were to go awry.include any changes made since initializing the git repo. It will also add the message provided as the commit’s message that will show in the git logs when viewed by others or yourself at a later time. I would recommend something descriptive to tell you what that commit actually changed.
At this point, you have completed one full cycle of the git process. You can keep going about your own business and just keep making changes and committing the changes as you make them. One other benefit of a version control system is the ability to upload to places and have backups out on the interwebs. Some examples are https://github.com, https://bitbucket.org/. I will be going further into detail in another article which will cover, pushing and rebasing using remote hosts. In the mean time, feel free to take a peek at some git resources I have gathered below: