Select your PC environment:

In the tutorial directory that we have created earlier, we are going to add a new file and have it registered under the repository.

Create a file named "sample.txt" in that directory with the following text content.

Git commands even a monkey can understand


Open the tutorial directory and right-click on an empty space to open the right-click menu. Then, click "Git Commit" from the right-click menu.

The following screen will be displayed. Make sure the sample.txt from "Changes made" is checked. Now enter a commit message in the message box and click "OK".

Enter a message in the "commit message" field, then click the "OK" button.

The following progress bar screen will be displayed. If it's all good, click "Close" to finish.

If it says "Success," the attempt was successful.

Click TortoiseGit > Display Log from the right-click menu. You will find that the commit that we have just added is now listed under the history list. We have successfully commited a file!

The recent commit is added to the history.


Double click on the "tutorial" repository under the SourceTree bookmarks window. You will now see a repository operation window. If there are any newly added or edited files within the directory, they will be displayed at the bottom left of the work tree file inspector.

Because we have just added the "sample.txt" file into the "tutorial" directory, we can see it being listed there.

Repository screen

Right click on the "sample.txt" file and choose "Add to Index". The file will now be moved to the "Files staged in the index" list above.

Click "Add to Index"

Click "Commit" in the toolbar and we will see the following screen. Enter a Commit message and click "Commit"

Enter commit message and click commit button

Once the commit is done, you will find the newly added commit being added to the "master" branch history. You can verify that the new commit is successfully added by clicking the "master" branch on the left menu.

The commit is added.

Command Line

We can use the "status" command to confirm the status of our Git working tree and index.

$ git status

Let's execute the "status" command and inspect the status of the tutorial directory.

$ git status # On branch master # # Initial commit # # Untracked files: # (use "git add ..." to include in what will be committed) # # sample.txt nothing added to commit but untracked files present (use "git add" to track)

As we can tell from status response, "sample.txt" is currently not being tracked. You will need to add "sample.txt" to the index first in order to track its change.

In order to do that, you will use the "add" command followed by the that you wish to add to the index. If you would like to add multiple files to the index, you can do so by separating them with a space.

$ git add ..

Specify "." instead of individual file names, if you wish to add all of the changed files to the index.

$ git add .

Now, let's verify that "sample.txt" has been successfully added to the index.

$ git add sample.txt $ git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached ..." to unstage) # # new file: sample.txt #

Now that "sample.txt" has been added to the index, we can proceed with committing the file. Use the "commit" command shown below.

$ git commit -m ""

After executing the “commit” command, check the status.

$ git commit -m "first commit" [master (root-commit) 116a286] first commit 0 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 sample.txt $ git status # On branch master nothing to commit (working directory clean)

The "status" command response tells us that there are no more new changes to be commited.

We can see the newly added commit in the repository's history log with the "log" command.

$ git log commit ac56e474afbbe1eab9ebce5b3ab48ac4c73ad60e Author: eguchi Date: Thu Jul 12 18:00:21 2012 +0900 first commit

If you prefer a GUI way of diving into the repository history, you can do so using "gitk" that is shipped along side with Git.

$ gitk

Next up, we are going to share our repository with other members in the team.