Http://rfyiamcool.blog.51cto.com/1030776/1150287
This is the process concept diagram of git ~ Clear at a glance ~~~
Git consists of three main zones: workspace, temporary storage zone, and version library.
Workspace: folder currently working
Temporary Storage Area: You can submit the changes to the cache area and save them. The cache of the submitted task. Add. git/index
Version Library: the Server File commit. git/objects |
Git advantages ~
Suitable for distributed development with emphasis on individuals.
The pressure on public servers and the amount of data will not be too large.
Fast and flexible.
Any two developers can easily resolve conflicts.
[Installation and initialization]
1. Configure the global user name and email address
git config –global user.name “owenrui”
git config –global user.email ruifengyun@naver.com
2. initialize the version library.
Create library folder
Mkdir/root/to/repo
Cd/root/to/repo
Initialization
Git init
Put all the files in the workspace in the temporary storage area.
Git add.
Submit to local database
Git commit-m "initial import"
Clone version Library
git clone https://github.com/gitlabhq/gitlabhq.git
[Submit Code]
Submit the changes in the directory to git.
Submit the content in the Workspace
Echo "aaaa"> aa
Git add aa
Git commit-m "add file aa"
The annotation added after the above command git commit-m can be either double quotation marks or single quotation marks. The annotation content can also be Chinese
Push to the remote git repository ~
Then, view the aa file we pushed on the git server.
Temporary File modifications that have been included in git Version Control
Git add aa
Submit all modifications to files under git Version Control
Git commit-m "add file aa"
Clear changes in the working directory tree
Git checkout HEAD aa
Cancel the temporary ID that has been saved but has not been submitted
Git reset HEAD aa
[History]
Show all history records
Git log
Display version history and content differences between versions
Git log-p
Show only the last submission
Git log-1
Displays the last 20 submissions and content differences between versions.
Git log-20-p
Show submissions in the last 6 hours
Git log-since = "6 hours"
Displays the submissions two days ago.
Git log-before = "2 days"
Displays the three commits earlier than the HEAD (the ending point of the current branch ).
Git log-1 HEAD ~ 3
Or
Git log-1 HEAD ^
Or
Git log-1 HEAD ~ 1 ^
[Advanced functions]
Git revert:
To restore a version modification, you must provide a specific Git version number, for example, 'git revert bbaf6fb5060b4875b18ff9ff637ce118256d6f20 '. The git version number is a generated hash value.
Git checkout:
Git checkout has two functions. One is to switch between different branchs. For example, 'git checkout new_branch 'switches to the new_branch branch. The other function is to restore the code, for example, 'git checkout app/model/user. rb, the user. the rb file is updated from the previous submitted version. All unsubmitted content will be rolled back.
Git reset:
Roll back the current working directory to the specified version. Suppose, for example, we have the version submitted five times by the A-G, where the C version number is bbaf6fb5060b4875b18ff9ff637ce118256d6f20, we executed the 'git reset bbaf6fb5060b4875b18ff9ff637ce118256d6f20 ', then the result is only three submitted versions of the A-C.
Differences between git revert and git reset
Git revert is used to cancel an operation. The commit before this operation will be retained.
Git reset revokes a certain commit, but all subsequent modifications will be returned to the temporary store.