Git basic command action
A. First, understand the git operation flow:
A.txt.local---[add]---> a.txt (staged)---[commit]---> a.txt.remote
1. Explain the above operation flow (local-server): We can understand that there are three stages: 1. Local, 2. Staging, 3. Server. That is to say we submit the newly modified file to the server, there are two ways: 1-2-3,1-3. These two methods correspond to the operation is A:add+commit, B:commit-a.
A.txt.remote---[Commit--amend]---> a.txt (staged)---["Git reset HEAD <file> ..."]---> a.txt.local ( Modified)---["Git reset HEAD <file> ...."]--->a.txt.local (original)
2. Explanation of the above cancellation stream (server-local): (1) If we submit to the server, missing a few files are not added, or the submission information is wrong: Commit--amend will submit the staging area, and then edit the submission information from the new. (2) If we want to go back to unstaged from staged, then run git reset Head <file> command, if the command is too long you can use Git--global config alias.unstaged ' reset head ' To rename the parameter, the next time git unstaged <file> is ready. (3) If we modify the file want to go back to unmodified when you can use git checkout-<file> You can also use Git--global config alias.ck ' checkout-', Next run git ck < File> on the line.
B. Second, remote warehouse operations:
1. Take it Over
Git remote show looks at the URL of the local project remotely.
git clone [url] clones the project from the GitHub project address, then automatically tracks its branches and merges.
git remote add [shortname] [url] If we initialize a local project via Git init, there is no far end, this command allows you to add and name, or add multiple remote.
git fetch [remote-name] gets the project through a different remote, and the fetch project is not merged and feels like a wget.
git remote show [remote-name] can use this command to view the remote information situation
2. Give the past
git push orgin branch-name we push to the Branch-name branch of the Orgin remote.
Git remote rename s1 s2 Rename the remote to the local settings s1->s2
Git remote RM s1 Delete the local remote S1 set
C. Finally, let's look at the additional action:
git log first-level parameter
Options |
Description |
-p |
Displays the differences between each update in a patch format. |
--word-diff |
Displays differences by word diff format. |
--stat |
Displays the file modification statistics for each update. |
--shortstat |
Only show the last number of lines in--stat Modify add remove statistics. |
--name-only |
Displays the modified list of files only after the information is submitted. |
--name-status |
Displays a list of new, modified, and deleted files. |
--abbrev-commit |
Displays only the first few characters of the SHA-1, not all 40 characters. |
--relative-date |
Use a shorter relative time display (for example, "2 weeks Ago"). |
--graph |
Displays the branch merge history represented by an ASCII graphic. |
--pretty |
Displays historical submission information in a different format. The available options are Oneline,short,full,fuller and format (followed by the specified format). |
--oneline |
--pretty=oneline --abbrev-commit simplification of usage. |
1. View Submit Log
Two uses are briefly described:
Git log-p-2--word-diff-p by comparing the last commit, 2 is showing the last two times. --word-diff is a very simple display of word-level changes.
git log--pretty=online single-line display format.
git log--pretty = format: "", the inside of the two-level parameters such as, the middle plus the space is OK, private customization, very convenient
Options |
Description |
%H |
Full hash string for commit object (commit) |
%h |
A short hash string for the Commit object |
%T |
Full hash string for tree object |
%t |
A short hash string for a tree object |
%P |
Full hash string for parent object |
%p |
Short hash string for parent object |
%an |
The name of the author (author) |
%ae |
Author's e-mail address |
%ad |
Author revision date (can be customized with-date= option) |
%ar |
Author revision date, as of how long ago the way display |
%cn |
The name of the submitter (committer) |
%ce |
Submitter's e-mail address |
%cd |
Date submitted |
%cr |
Submission date, as of how long ago the way it was displayed |
%s |
Submission Instructions |
2. Operation Version Information
git tag to show all tags
git tag-a v1.4-m ' My first version 1.4 ' is used to add a label with a staple
Git show v1.4 can be used to see the comments on this tab
Git push origin [tagname] can be labeled push to server side
3. Git cheat-sheet
Https://training.github.com/kit/downloads/cn/github-git-cheat-sheet.html (Chinese version)
Citation Link: http://git-scm.com/book/zh/v1
Summary of git command line learning ideas