Git Series 3: git configuration and Usage Guide in Windows-reprint

Source: Internet
Author: User
Tags git client netbeans
Git Series 3: git configuration and Usage Guide for windows I. Installation

Default installation: msysgit

Ii. Configuration

1. Add c: \ Program Files \ git \ etc \ gitconfig:
Note !] Change "Your-ID" at the end of the second line to your actual ID on the server. The default name is pinyin.

[Alias] Go = "! Bash-C \ "Git pull & git Add .; if [\\\ "$ * \\\" =\\\ "\\\"]; then git commit-; else git commit-am \ "$ * \"; FI; git push origin master: Your-ID; \ "" [core] autocrlf = false [GUI] encoding = UTF-8 [i18n] commitencoding = gb2312 [user] email = xxx@gmail.com name = xx

2. c: \ Program Files \ git \ etc \ inputrc:

set output-meta onset convert-meta off

3. c: \ Program Files \ git \ etc \ git-completion.bash added at the end:

alias ls='ls --show-control-chars --color=auto'

4. Add the following content at the end of c: \ Program Files \ git \ etc \ profile:

export LESSCHARSET=utf-8

Tip: it is best to use an editor that supports UNIX format to modify the above files (such as NotePad ++ and netbeans), and use "WordPad" instead of "Notepad" for the most time ".

Tip: For more information about the settings, see git client Selection in windows and how to solve various Chinese problems in msysgit.

3. Generate a key

After the installation, you must generate a pair of keys (the key here) before you can synchronize with the server code library through encryption.

Go to the Start Menu, find "Git Bash", run it, and execute the following command:

$ ssh-keygen -t rsa

The program prompts you to enter the name of the key and press Enter.
Then you will be asked to enter a password, which will be provided when you use the key in the future. You can enter or press enter without entering it. (either input or not, you are required to confirm it once ).
After confirmation, the program will generate a pair of keys stored in the following folders:

C: \ Users \ Administrator [replace this with your username] \. SSH

The key is divided into two files, one private key (id_rsa) and one Public Key (id_rsa.pub ).
The private key is saved on your computer, and the Public Key is handed over to the project owner and added to the server. You must have the private key that is paired with the public key of the server to access the code library on the server.

Note !] For project code security, please keep your private key safe! Once the private key is leaked, the code on the server may be leaked!

Iv. Use 1. Clone the code library

Use Windows Resource Manager to open the folder where you plan to store the project code, right-click and select git bash.

In our project management system, the home page of each project contains the address for code cloning. For example, the sandbox project we use for testing purposes:

$ git clone your-name@testing.aysaas.com:/var/projects/sandbox

Run this command in git Bash to clone all the code in the sandbox project (in fact, just a few casually tested files) to the local machine.

Then you can open the familiar IDE (such as netbeans) and invest it in project development ~!

Tip: Change the your-name in the preceding command to your actual user name on the server.

2. view the modification differences

During development, if you want to know which code has been modified and view all the code changes, you can enter this command in git Bash:

$ git diff

Tip: git bash diff has two disadvantages: 1. The window is too narrow and the entire line of code may not be displayed. 2. If the Code contains Chinese characters, garbled characters are displayed. If you encounter these two problems, right-click the project folder and select git GUI.

3. Submit changes

Every time you complete the code at a stage, you need to submit the code to record the progress, so that you can find problems and team collaboration in the future.

$ Git go AAA modification description (changed? Why ?)

[Tip] Don't forget AAA behind go. For details about the 'git go 'command, see the GIT client Selection in windows and how to solve various Chinese problems in msysgit.

Tip: Please try to develop a good habit of regular submission. When the code encounters an unfortunate problem, it is easier to find out the starting time of the problem and go back to the time for debugging to maximize the protection of the completed phase work.

Tip: all the preceding commands must be run in the project directory. Git bash displays the current directory before the command prompt. If the current directory is not under the project directory, use the CD command to switch to the directory where the project is located.
The simple method is to open the project folder in the resource manager, right-click it, and select git bash.

V. Summary

Now, the entire process is familiar with getting code, viewing differences, and submitting code. GIT also has relatively advanced skills. You can refer to git advanced features or learn more online.

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.