Lab 4: Making Changes to files in the Working Directory

In this tutorial I will show you how to monitor the state of the working directory.

Change the hello.txt file

We now edit the hello.txt file to add a simple HelloWold class to it. Change the file to be:

#include <stdio.h>

int main() {
   printf("Hello, World! \n");
   return 0;
}

Check the status

Now check the status of the working directory by executing the git status command.

git status

You should see the following output:

Git modified files

Notice that git knows that the hello.txt file has been modified but it has not yet been notified of these changes.

The status message hints about what you need to do next. If you want to add these changes to the repository, then use the git add command. Otherwise the git checkout command can be used to discard the changes.

All posts in this series:
Lab 1: Setup Git on your Machine
Lab 2: Create a Git Repository from Scratch
Lab 3: Check the Status of the Repository
Lab 4: Making Changes to files in the Working Directory
Lab 5: Staging Changes in Git
Lab 6: Git Staging and Commiting

Other related posts:
Git Delete a Local or Remote Branch
How to Clone a Git Repository into a Specific Folder?
Change the URI for a Remote Git Repository
How to Merge a Local Git Branch with Master
How to Setup Aliases and Shortcuts for Git Commands
How to create a .gitignore file in Windows

This content has been helpful to you?

Thanks for contributing!

Yes No