Git is a version control system which allows past revisions of your HTML code to be recorded, and can be retrieved easily when needed. It also makes collaborating on a project with a team of different people much easier, where each member work on a version of the project. Editing a HTML file on your desktop makes a new version of your project. This project can be then pushed into the Remote Repository where changes is reflected on the website. Git also allows user to retrieve a repository on the web and edit it locally. This can be done with commands.
- Git Clone: Make a copy of an existing website and saves it in your hard drive.
- Git Pull: Bring down a current version of the remote repository to work on it.
- Git Add: Add files from your desktop into the staging area.
- Git Commit: Commit changes made into the local repository.
- Git Push: Copies the files on the local repository into the remote repository.
Whenever changes are made in the HTML document, Git desktop will capture this changes and notify the user about this changes made. They will also show the changes made in the different files in your HTML project.
You can choose to select which changes you want to discard/keep by selecting the files with the checkbox. You can discard the selected change by right clicking "9 changed files" and clicking "Discard all changes". You can also individually discard changes by right clicking on the file itself instead. If you want to keep the changes made in the selected files, you need to provide a summary of the changes that you make, and click "Commit To Master". After that, to update your website with the changes made, you can "Push to Origin"
If you were to push some changes that you would like to retrieve, you can easily do that by going to history, right clicking the change you want to revert, and click "Revert". I tested this function on the paragraph below.
I used Github desktop to use git and tested it by putting this paragraph into my html file, deleted it, and tried to recover the paragraph. This can be done by reverting a previous version.