Git tutorial-time Machine Shuttle

Source: Internet
Author: User

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 statuscommand 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 diffAs 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 statusTell 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.