Information Technology Reference
In-Depth Information
7. Commit the changes with $ git commit -m "Staging and
committing a modified file"
8. Check the status with the $ git status -s command. The output is
empty, therefore the repository is clean.
How It Works
Recipe 4-2 starts with a modification of a file that was already stored in revision. We
will modify the file with:
$ echo Some other text > modified.txt
After this operation the file becomes modified . To find out what git thinks about the
file, we issue the command:
$ git status
The file is listed under Changes not staged for commit . Therefore, we can say that
the file is modified and unstaged . It is also tracked . But every unstaged file is tracked
and modified. Hence, it is enough to say that the file is unstaged . Files that were previ-
ously committed after some modifications are labeled as _M by the $ git status
-s command.
To add the unstaged file to the staging area we use the $ git add command.
After:
$ git add modified.txt
the file becomes staged . Its short label is now M_ (the M letter followed by a space).
Finally, we commit the staged file with:
$ git commit -m "Some comment..."
And the file is unmodified again.
Recipe 4-2 is depicted in Figure 4-2 .
 
Search WWH ::




Custom Search