Git operation examples

Source: Internet
Author: User
Tags connection reset hosting git commands

The first three articles introduce git concepts, command usage, command query, and other theoretical knowledge.

1) git version management tool

2) git Common commands

3) Quick query of common git commands

This article mainly introduces several problems encountered during the use of git and their solutions.

I. Git GUI and command line operations

Git manages code versions in two ways: Gui and command line

Gui: There are platform restrictions. Currently, only Windows systems are supported. Linux (UNIX) adopts the command line mode, and the number of display files is limited each time the graphic interface is submitted (for example: A maximum of 20000 files can be displayed)

Command Line: no platform restrictions. supported in Windows and Linux (UNIX and Mac OS X). You can use GID add DIR/files to add files without restrictions on the number of files.

 

The following describes how to manage and operate git:

1. Gui

First, download the GIT graphical interface tool in Windows: msysgit or official download

Next, install msysgit, such as download the latest Git-1.7.10-preview20120409.exe after installation, the operation methods are git GUI and git bash, the default is GUI bash only

After the installation is complete, Go to Start> All Programs> git. There are two icons: git bash and git gui. Click the following to start the GIT Gui:

 

The msysgit graphical tool allows you to create a new version Library (local), clone an existing version Library (remote), and open an existing version Library (local or remote)

For example, to clone an existing version Library (remote), for example, to clone and download a Linux-kernel-Source:

A. Click "clone existing version library" and enter the remote version Library (XXX) and local directory (XXX) in sequence, as shown in figure

 

2. Command Line

A. Git remote download

Git clone git: // git.kernel.org/pub/scm/ project_path

1) For example, to download Linux-kernel-source, the GIT command is as follows:

Git clone https://code.google.com/p/linux-kernel-source//e/fruit/code_google/Linux-kernel-TMP

2) For example, download the Linux kernel git.kernel.org.

Git clone git: // git.kernel.org/pub/scm// home/Homer/Linux-kernel-3.3.4

 

B. Local git upload

Add a new file: git add DIR/Files

Submit the file: git commit

Upload File: git push

2. Password-less logon to Google Code git in Windows

Every time you use git to push code to Google Code, you always need to enter the user name and password, which is very troublesome. Google Code provides a method to save authentication information on the project management page:

Option 2This is the configuration for password-free logon. However, this configuration is for Linux systems. Is there any configuration similar to. netrc in windows?

The answer is yes. To complete the configuration of. netrc in windows, two steps are required: 1. Create the home environment variable; 2. Create the _ netrc file and enter the configuration information.

1. Environment Variables

If you are using Windows 7

Run the CMD type this:

Setx home % USERPROFILE % (Note: %USERPROFILE % is the current default user directory)

And the % home % will be set to 'C: \ Users \ "username "'

For example, if the user name is Homer, % home % will be set to 'C: \ Users \Homer'


2. Configuration _ netrc

Windows. NetrcFile Name_ NetrcProcedure:

First, create a new name in the % home % directory (C: \ Users \ Homer) specified in [1. Environment configuration]_ NetrcFile

Then_ Netrc, Enter the following content:

Machine code.google.com login xxx@gmail.com password XXX [generated googlecode.com Password] 

Where, password is automatically generated by code.google.com, in profile-> Settings-> googlecode.com password (https://code.google.com/hosting/settings)

 

Git push does not need to input a password for uploading:

Recommended reference: stackoverflow

Iii. Google Code-managed open-source project https://code.google.com/hosting/settingsresolution Method

Method 1:

Many people in code.google.com, all need a code.google.com password, this password is obtained from the https://code.google.com/hosting/settings URL, but most of the time you will find this URL cannot open, the reasons for practical analysis may be as follows:

1. The country has blocked the IP address of www.google.com.

2. Due to national blocking, Google.com was forced to change its IP address.

Solution:

1. Ping www.google.com on the command line to check the IP address of Google.com.

2. Modify the c: \ windows \ system32 \ drivers \ etc \ hosts file

 

74.125.153.104 is the IP address that you see when you ping.

Append the following content:

74.125.153.104 code.google.com
74.125.153.104 encrypted.google.com
74.125.153.104 suggestqueries.google.com
74.125.153.104 mail.google.com
74.125.153.104 groups.google.com
74.125.153.104 groups.google.com.hk
74.125.153.104 docs.google.com
74.125.153.104 docs0.google.com
74.125.153.104 docs1.google.com
74.125.153.104 spreadsheets.google.com
74.125.153.104 spreadsheets0.google.com
74.125.153.104 webcache.googleusercontent.com
74.125.153.104 sites.google.com
74.125.153.104 talkgadget.google.com
74.125.153.104 clients1.google.com
74.125.153.104 clients2.google.com
74.125.153.104 clients3.google.com
74.125.153.104 clients4.google.com

 

Method 2:

At the beginning of code.google.com can be accessed, almost all pages can be accessed, only view SVN account password page (https://code.google.com/hosting/settings) is always "Connection Reset"

Because of the well-known reasons, I was about to block this critical page because I didn't want people to submit code to the US emperor. Through Baidu's query, I found that although their solutions were all changed to hosts (method 1), but I was not right about how to change the solution. I verified it myself and found that the following methods are more reliable.

If you already have a method for turning over, you can just turn over the access. My method is for the case of not turning over.

Someone on the Internet said that we should ping www.google.com and code.google.com and set hosts with the IP address in the result !!!

Why? Because our Ping has been castrated by the wall, for example, Ping www.google.com. The result may be Ping code.l.google.com, which has been tampered.

What should we do if we want to get ping results like the US emperor?

It's very easy. Search for online ping on Google first, find the first or eye-catching website, and use the online ping tool inside to ping code.google.com, which is equivalent to using a foreign server to ping, therefore, the results are reliable.

 

Summary:

1. Go to Google to search for online Ping, search for it in English, or directly open ping. eu/ping

2. On a foreign website that provides online Ping, enter Ping code.google.com to obtain the IP address.

3. Modify the hosts file and match the IP settings that you just pinged with code.google.com. (You 'd better clear the DNS Cache and enter ipconfig/flushdns in the command line)

Reference recommendations:

Password-free logon to Google Code git in Windows

Git GUI and command line

Google Code hosting open-source project https://code.google.com/hosting/settingsresolution Method

Git version management tool

Git Common commands

Quick query of common git commands

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.