Skip to main content

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

Section 3.4 Editing Local Files

In the last two sections you created a feature branch and switched to that branch. In this section you will edit your local files to fix the issue that you claimed in the issue tracker.

Exercises

1.

In order to make the changes to the appropriate local file, you will need to review the issue that you claimed.
Provide a link to the issue that you claimed in the issue tracker.

2.

Read the issue that you claimed.
(a)
In which file will you be making changes to address your issue? Hint: Look at the text of your issue in the issue tracker.
(b)
Use a text editor to modify the file you identified in Task 3.4.2.a so that the issue you claimed has been fixed. Be sure to save your changes.
Figure 3.4.1 illustrates the current situation where your Local Files have been modified. In Figure 3.3.1 the Local Files in your feature branch were drawn in green. This reflected that they were, at that time, an exact copy of the last commit on the main branch, which was also drawn in green. Here Local Files are drawn in blue to indicate that they have been changed as compared to the final commit in the main branch, which is still green.
Editing local files on a feature branch.
Figure 3.4.1. Editing Local Files on a Feature Branch.

3.

The git status command can now be used to check that your changes have been made. Run the git status command now.
What does the output tell you about the current status of the repository? If you see the message "nothing to commit, working tree clean", it means that your edits in the previous exercise were not saved. Go back and save your edits and then issue the git status command again before answering the questions below.
(a)
    How many files are not staged?
  • 0
  • Perhaps you didn’t save your change. Try editing the file again and make sure you save it.
  • 1
  • Correct! The file you changes has been modified but not staged yet.
  • 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.
Not staged means a file has been modified but not added to the commit.
(b)
    How many files are added to the commit?
  • 0
  • Correct! You have not added any files to the stage yet.
  • 1
  • Unless you already issued the git add command you shouldn’t have any files ready to be committed.
  • 2
  • Unless you already issued the git add command you shouldn’t have any files ready to be committed.
  • 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.
If a file has been modified but not added it will not be part of the commit.

4.

The git diff command provides another way to examine or confirm the changes you have been making. Note diff is just short for difference, and is called this because it is used to show differences. By default the git diff command will show you any changes that have been made to your local files as compared to the version in the most recent commit in the active branch. Run the git diff command now.
(a)
    How is the change that you made indicated in the output from git diff?
  • The new text is in red, the old text is in green.
  • Look again to see what color your change appears in.
  • The new text is in green, the old text is in red.
  • Correct! The original text is in red, your changes are in green.
  • Only the new text appears.
  • Look again, you should see the original text as well.
  • The old text appears with a strike-through line across it.
  • Strike-through is not part of the feedback git commands can provide.
Hint.
Look at the feedback again and look for your change. Do you also see the original text?
You have attempted of activities on this page.