Android environment configuration: Summary of git concepts and Common commands for distributed version control

Source: Internet
Author: User

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 ~

 
 
  1. Suitable for distributed development with emphasis on individuals.

  2. The pressure on public servers and the amount of data will not be too large.

  3. Fast and flexible.

  4. Any two developers can easily resolve conflicts.

[Installation and initialization]

 

1. Configure the global user name and email address

 

 
 
  1. git config  –global user.name  “owenrui” 

  2. git config  –global user.email  ruifengyun@naver.com 

 

2. initialize the version library.

 

 
 
  1. Create library folder

  2. Mkdir/root/to/repo

  3. Cd/root/to/repo

 

 
 
  1. Initialization

  2. Git init

  3. Put all the files in the workspace in the temporary storage area.

  4. Git add.

  5. Submit to local database

  6. Git commit-m "initial import"

Clone version Library

 
 
  1. git clone https://github.com/gitlabhq/gitlabhq.git 

 

[Submit Code]

Submit the changes in the directory to git.

 

 
 
  1. Submit the content in the Workspace

  2. Echo "aaaa"> aa

  3. Git add aa

  4. 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.


Related Article

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.