>_ IzzyLab

Hands-on task

This task is step 3 of the course “Git: first commits”

What changed: git status

easy~4 min

Someone has worked in the /root/shop repository since the last commit: one of the files already in the commit was changed, and a new file appeared that git doesn't know about yet.

Find out which file already saved in git was changed and write its name to /root/answer.txt, for example like this: echo file_name > /root/answer.txt.

What you'll practise:
  • git status
  • modified files
  • untracked files

Topic breakdown

Git compares the files in the directory with the last commit and sorts them into groups. git status shows these groups:

  • Changes to be committed — changes already in the index; they'll go into the next commit;
  • Changes not staged for commit — git knows the file (it's in the commits), and it has been changed but not added to the index yet;
  • Untracked files — new files that aren't in any commit.

The short form is git status -s, one line per file:

 M notes.md      # modified, not in the index yet
A  todo.md       # added to the index
?? draft.md      # new, git doesn't track it

A habit that saves you from mistakes: run git status before every git add and git commit — that way you see exactly what is about to go into the history.

What's checked

  1. File /root/answer.txt created
  2. The answer is the changed file that was already in the commit

What it looks like