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.txtThe 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.txtNotice 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
EasyThe 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.txtStage the modification with git add, which moves M to the left column (staged):
git add hello.txt
git status --short
M hello.txtThen commit as usual:
git commit -m "Update hello.txt"Try it yourself
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Version Control
2Getting Started
Initialize A RepositoryThe .git FolderConfigure Your IdentityGit StatusRecap - First Repo8Merging
What Is A MergeFast-Forward MergeThree-Way MergeMerge ConflictsResolve A ConflictRecap - Merge Master11Feature Branch Project
Project OverviewInitialize Main3Tracking Changes
The Staging AreaGit AddGit CommitModifying A Tracked FileGit LogRecap - First Commits6Recipe Site Project
Project OverviewInitialize And Ignore