Menu
Coddy logo textTech

Modifying A Tracked File

Part of the Version Control section of Coddy's Terminal journey — lesson 12 of 58.

Once a file has been committed, Git tracks it. The next time you edit it, git status shows it as modified rather than untracked.

git status --short
 M hello.txt

The M in the second column means "modified in the working directory but not yet staged". You stage modifications with the same git add command:

git add hello.txt
git status --short
M  hello.txt

Notice the M moved to the first column. The two columns are staged (left) and working directory (right). Once staged, you commit the change like any other:

git commit -m "Update hello.txt"

Each commit captures a complete snapshot, so you do not lose the old version. You can always look back at it.

challenge icon

Challenge

Easy

The folder contains note.txt. Initialize the repo, configure user identity, commit the original file, then change the file's contents to updated, and run git status --short.

The expected output is the modified-but-not-staged marker.

Cheat sheet

After editing a tracked file, git status --short shows M in the right column (modified, not staged):

git status --short
 M hello.txt

Stage the modification with git add, which moves M to the left column (staged):

git add hello.txt
git status --short
M  hello.txt

Then commit as usual:

git commit -m "Update hello.txt"

Try it yourself

Terminal
quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Version Control