We have successfully added and submitted a Readme.txt file, and now it is time to continue working, so we continue to modify the Readme.txt file and change it to the following:
is a distributed version control system.Git is free software.
Now, run the git status
command to see the results:
$ git status# On branch master# Changes not staged for commit:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: readme.txt#no changes added to commit (use "git add" and/or "git commit -a")
git status
command allows us to keep abreast of the current state of the warehouse, the above command tells us that Readme.txt has been modified, but not ready to commit the changes.
Although Git tells us that Readme.txt has been modified, it's good to see what's changed. For example, you take a vacation two weeks from abroad, the first day of work, have not remember the last how to modify the Readme.txt, so, need to use git diff
this command to see:
46d49bf..9247db6 100644--- a/readme.txt+++ b/readme.txt@@ -1,2 +1,2 @@-Git is a version control system.+Git is a distributed version control system. Git is free software.
git diff
As the name implies is to view difference, the format is the UNIX common diff format, you can see from the command output above, we added a "distributed" word in the first line.
Know what changes to Readme.txt, and then submit it to the warehouse is much more assured that the submission of changes and submit a new file is the same two steps, the first step is git add
:
$ git add readme.txt
There is also no output. Before performing the second step git commit
, let's run through git status
the status of the current warehouse:
$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: readme.txt#
git status
Tell us that the changes to be submitted include Readme.txt, the next step, and you can safely submit:
commit -m "add distributed"[master ea34578] add distributed 1 file changed, 1 insertion(+), 1 deletion(-)
Once submitted, we then use git status
the command to see the current state of the warehouse:
$ git status# On branch masternothing to commit (working directory clean)
Git tells us that there are no changes that need to be committed at this moment, and that the working directory is clean (working directory cleanly).
Summary
To keep track of the status of your workspace, use the git status
command.
If git status
you are told that a file has been modified, you git diff
can view the modified content.
Git tutorial-time Machine Shuttle