Version Control-git (2), version control-git

Source: Internet
Author: User

Version Control-git (2), version control-git

The last article introduced some basic knowledge of Git (http://www.cnblogs.com/jerehedu/p/4582398.html), and introduced the use of git init to initialize the version library, use git add to add files to the version library, use git status to view the status information of the version library, and use git commit to finally submit the file to the version library. At the end of the submission, the submission fails because git is not configured.

Git Configuration

The most important configuration information of Git is the user name and email address. Each Git commit uses these two messages to identify who submitted the update.

  Run git config.

$ git config –global user.name “jredu”  

$ git config –global user.email jredu@jredu.com

The above two commands can be used to configure the user name and Email information for git. Note that the above two commands contain the "-global" parameter, which means that the configuration is global, all git projects use the user name and email configured above as the commit user ID.

If you do not want to use global user configuration information for some projects, you can configure them separately. The specific command is as follows:

$ git config user.name “jredu001”

$ git config user.email jredu001@jredu.com

How to view Git configuration information

After the information is configured, how can we view the Git configuration information? Follow these steps.

  Run git config-list.

 

In addition to the preceding command, you can view the information by opening the specified configuration file. The global configuration information of Git is stored in "~ In the/. gitconfig file, we can view it using the following command:

$ cat ~/.gitconfig

The configuration file of a single project is stored in the ". git/config" file in the directory of the git project, as follows:

Run $ cat. git/confg

Version update operations

After completing the preceding configuration, we can use the name mentioned in the previous article to submit the file.

 

Then, git marks the state of the file as modified. We will put the modified files into the temporary storage area and will be submitted. Version Management is completed by repeating this step. In git, the file status changes are shown in:

 

The following is an example of how to submit a modified version control file:

  1. Modify the readme.txt file.

 

  2. Use git status to view status information

 

3. Use git addto Add the modified file readme.txt to the temporary storage zone.

 

4. Use git commit for submission

 

Delete an object

To delete a file, you need to delete it from the list of Tracked files, and then submit Git with the command: git rm

 

In addition to the basic usage, git rm can also combine some parameters to complete more powerful functions. The specific content of the parameters is as follows. You can test them by yourself.

 

File rename

Sometimes we want to rename the tracked files. The specific operation command is git mv old_file new_file.

View submission logs

After multiple updates are submitted, you can use the git log command to view the Historical submission records.

For example, if you use the git log command, by default, git will display the updates in descending order based on the submission time. The displayed content mainly includes SHA-1 verification, author, submission time, and submission instructions. The git log command can work with parameters to provide more powerful functions, as shown in:

 

For questions or technical exchanges, please join the official QQ group: (452379712)

 

Author: Jerry Education
Source: http://www.cnblogs.com/jerehedu/
The copyright of this article belongs to Yantai Jerry Education Technology Co., Ltd. and the blog Park. You are welcome to repost it. However, you must keep this statement without the author's consent and provide the original article connection on the article page, otherwise, you are entitled to pursue legal liability.

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.