lab 4 Making Changes

Goals

Change the “Hello, World” program. 01

It’s time to change our hello program to take an argument from the command line. Change the file to be:

File: hello.c

#include <stdio.h>
int main(int argc, char *argv[])
{
  if (argc > 1) {
    printf("Hello %s!\n",argv[1]);
  } else {
    printf("Hello World!\n");
  }
  return 0;
}

Check the status 02

Now check the status of the working directory.

Execute:

git status

You should see …

Output:

$ git status
On branch master
Changes not staged for commit:
  (use "git add ..." to update what will be committed)
  (use "git checkout -- ..." to discard changes in working directory)

	modified:   hello.c

no changes added to commit (use "git add" and/or "git commit -a")

The first thing to notice is that git knows that the hello.c file has been modified, but git has not yet been notified of these changes.

Also notice that the status message gives you 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.

Next, let’s see how to stage the change.

Table of Contents