Skip to main content

Committing Changes

The Aims​

The objective for this exercise is to become familiar with basic operations using the git command line tool.

Steps​

  1. Create a new folder, called “GitLab1” within the C:\course folder

Step 1 Screenshot

  1. Open the Git Bash application.

  2. Configure Git by running the following 3 commands using your own name and personal email address

git config --global user.name "Jo Shmo"
git config --global user.email jo.shmo@neueda.com
git config --global core.editor notepad
  1. Navigate to the GitLab1 folder – note that to specify the drive letter can use the folder structure in the format
cd /<<driveletter>>/<<folder>>

Step 4 Screenshot

  1. Run the command git init to configure your folder as a Git project

Step 5 Screenshot

  1. Using notepad, create a new file called “Readme.txt” – enter any content you like into this file and save it.

  2. Run the command git status to see what the current status of your workspace is.

Step 7 Screenshot

Note that the file you added is untracked and appears in red – this file is in your workspace but is not yet in the staging area.

  1. Run the command git add Readme.txt to add the file into the staging area.

  2. Run the command git status to see what the current status of your project is.

Step 9 Screenshot

Note that the file you added now appears in green. This file is in both your workspace and the staging area, and is the same file in both places.

  1. Make a small change to the file contents and save it. Then run git status again.

Step 10 Screenshot

Note that the file you added now appears in green – this is the file in your staging area. It is also shown in red as the file in your workspace is different to the file in your staging area

  1. Run the command git diff to see what lines have changed.

Step 11 Screenshot

In this example, the version in the staging area has the content “This is the first demo” and the version in the workspace has the content “This is still the first demo”.

  1. Run the command git add . to get the change into the staging area – note that the period at the end of this command means that all files in the workspace should be added.

  2. Run the command git status to see what the current status of your project is.  

  3. Run the command git commit -m "first commit" to move the file from the staging area into the local repo

Step 14 Screenshot

  1. Run the command git status to see what the current status of your project is.

Step 15 Screenshot

  1. Run the command git log to get a list of the commits on this branch

Step 16 Screenshot

  1. Commit some more changes to get comfortable with the operations:
  • Add at least one more file to the project
  • Make changes to each file – use the add and commit commands to move the files to the staging area and the repo
  • Use the status command to view the status of the project
  • Use the log command to view the commits
  1. Once you have added a few commits, use the command git log --oneline to view a shorter summary of the commits

Step 18 Screenshot