Skip to main content

GitKit (Linux Desktop Edition): Learn git and GitHub in Context

Section 3.5 Staging Changes

As you saw in the previous section, you now have modifications to your local files that have not been staged. The process of staging changes (i.e. adding the files to the stage) is illustrated in Figure 3.5.1. Recall from Figure 3.4.1 that the blue dot in Local Files represents the changes you made. In Figure 3.5.1, those changes are staged and will be made into a commit that is added to your feature branch in the next section.
Staging Changes.
Figure 3.5.1. Staging changes.

Exercises

The exercises in this section will walk you through staging the changes you made to your Local Files.

1.

The git stage <file> command adds the indicated file to the stage, preparing it to become a part of the next commit. Use the git stage <file> command now to stage the file that you edited.
(a)
Provide the command you entered.
(b)
Note that git also has a git add command that is equivalent to git stage. So, you can add files to the stage using either git stage or git add. These activities will use git stage because it seems more descriptive of what is happening. However, you are likely to see git add used in other resources, so it is worth knowing that they are equivalent. Provide the git add command that would be equivalent to your answer in Task 3.5.1.a.
(c)
    Now run the git status command again. Compare your output in Task 3.5.1.a to the output in Task 3.4.3.a.
    How many files are not staged?
  • 0
  • Correct! After issuing the git stage (or git add) command the file will be staged.
  • 1
  • Once you have issued the git stage command it show that the file is ready to be committed.
  • 2
  • Did you change more than 1 file by accident? Verify that you only changed the file specified in your issue.
  • Cannot be determined from the output provided by the git status command.
  • The git status command will show you all unstaged and staged files.
Hint.
Staged means a file has been modified and added to the commit.
(d)
    How many files are listed as ready to be committed?
  • 0
  • If you issued the git stage command properly the file you changed should appear as ready to be committed.
  • 1
  • Correct! After issuing the git stage (or git add) command the file will be staged.
  • 2
  • Did you change more than 1 file by accident? Verify that you only changed the file specified in your issue.
  • Cannot be determined from the output provided by the git status command.
  • The git status command will show you all unstaged and staged files.
Hint.
Staged means a file has been modified and added to the commit.
You have attempted of activities on this page.