Step 5 of Git

Source: Internet
Author: User

When initializing the repository, use git -- bare init instead of git init. If git init is used for initialization, the Directory of the remote Repository also contains the work tree, when a local warehouse is pushed to a remote warehouse, if the remote warehouse is being pushed to the branch (if the branch is not pushed at the time, there is no problem ), the push result will not be reflected on the work tree, that is, the corresponding file in the directory of the remote repository is still the previous content, you must use git reset -- hard to view the pushed content.
View historical records:
Git log
Git log-P-2 uses-2 to view the last two historical records and the commit change.
Git log-p -- word-DIFF: Check the change in the word. With-u1, only one change is displayed 「
Git log-start displays the number of modified lines and modified files.
Git log -- since = 2. weeks can display the history according to the time limit, or one day -- author displays the submission of the relevant author, -- grep searches for the keywords that submit the modification content, -- All-Match: display the first two
Matching information
Git log -- pretty = "% H-% s" -- author = gitster -- since = "2008-10-01" \ -- before = "2014-08-07" -- no-merges -- t/
Revoke history records:
Git commit -- Amend undo the submitted operation and resubmit it. The specific operations are as follows:
If you only want to modify the comments at the time of submission, go to git commit-M "Comments", git commit-amend, and enter the editor to modify the comments. However, the next time you submit the code, it will prompt
Updates were rejected because the tip of your current branch is behind in running git pull and remote merge, you can submit code, very troublesome !!!
If you forget to submit a file during modification and submit it again, you can also modify the comments,
Git commit-M "comment"
Git add file name
Git commit -- Amend (modify comments if you want)
Delete an object:
Git RM file name
Git commit-M "comment"
Git push remote branch to delete files
Cancel the GIT add file. Of course, it is easy to implement in the TIG status. You can also use the command line git reset head file name.
Git checkout -- the file name can be undone and returned to the State of the file when the project is cloned, that is, your modification is gone.

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.