Submodule 2.2: Version control. Git - Github

Basic Git Commands

In the folder yourNameWEB2, create a new subfolder yourNameWEB2GitTest.

Open this yourNameWEB2GitTest subfolder in your Visual studio editor.

Add a file named index.html to this folder and setup the file to show a title "Choco home" and a heading h1: "A site about chocolate". To do this just start typing ht and select html:5.

Visual studio editor auto completion

Modify the template

Visual studio editor HTML5 template

This is the code:

Right-click on this subfolder and select Open in Terminal. 

initialize the folder as a Git repository: 

git init

Git init

As Git just told us, our "yourNameWEB2GitTest" directory now has an empty repository in /.git/. The repository is a hidden directory where Git operates.

Type the following at the prompt to check your Git repository's status:

git status

git status

Good, it looks like our Git repository is working properly. Notice how Git says index.html is "untracked"? That means Git sees that index.html is a new file.

To add files to the staging area of your Git repository, type:

git add index.html

Good job! Git is now tracking our index.html file.

Let's run git status again to see where we stand:

git status

git add <file> and git status

Notice how Git says changes to be committed? The files listed here are in the Staging Area, and they are not in our repository yet. We could add or remove files from the stage before we store them in the repository.


To store our staged changes we run the commit command with a message describing what we've changed. Let's do that now by typing:

git commit -m "first commit for index.html"

git commit -m "Your message"

Great! You also can use wildcards if you want to add many files of the same type.

Let's run another

git status

git status after commiting

As we can see the working directory is clean, all files are committed.

To check the log of the commits to your Git repository, type

git log --oneline

git lof --oneline