Using Git

Git helps with version control. I’m working with a friend on a project and I’ve been using it to see what changes he has made. I haven’t gotten into some of other functionalities such as branching. I’ll walk through an easy example.

Let’s say I have an HTML file, index.html, in a folder below.

 <title>My Page</title>


To initializing tracking, I would go to the folder with the file on the command prompt and type in “git init”.


“Git add <filename or * for all>” adds these files to a staging area. You need to commit the files before changes can be tracked. ‘Git commit -m “<a message>”‘ stores these changes.

Now, if I make a change and type “git diff”, I can see what was added or deleted since my last commit.


“git add” and “git commit” saves these changes. If you do “git checkout  <filename>” , changes to these files will be discarded and the file will revert to the previously committed version.