Build a git Windows Environment

Source: Internet
Author: User

1. Download:

 

Http://code.google.com/p/msysgit/downloads/list (msysgit)

Http://code.google.com/p/tortoisegit/ tortoisegit

 

 

2. installation:

First install msysgit and then install tortoisegit. The installation process is simple. You can proceed to the next step. Configure the settings by default.

 

3. Configure git

Open the Start Menu ------> git --------> git Bash:

Configure the user name and email address:

-------------------------------------------------------------------

 

$ git config --global user.name "John Doe"$ git config --global user.email johndoe@example.com

 

----------------------------------------------------------------------

Configure the default Text Editor:

Git automatically calls an external text editor when you enter some additional messages. By default, the default editor specified by the operating system is used, which may be Emacs, Vi, or vim.

 

$ git config --global core.editor vim
Configure the difference analysis tool:
Another commonly used difference analysis tool is used to solve the merge conflicts. For example, to use vimdiff:
$ git config --global merge.tool vimdiff

View Configuration:
$ git config --list

You can also directly check the setting of an environment variable, as long as the specific name is followed, like this:

$ git config user.name
View help:

$ git help <verb>$ git <verb> --help$ man git-<verb>

For example, to learn how to use the config command, run:

$ git help config

 

3. Build a local database

There are two methods: command and Gui

A. Command method:

Open git Bash:

CD to the folder where you want to create a version Library:

1) run the following command:

--------------------------------

$ Git init


-------------------------------

2) Create the file to be added:

If several files in the current directory want to be included in version control, you must first run the GIT add command to tell git to start tracking these files and then submit them:

--------------------------------------------------------------

$ Git add *. c

$ Git add readme

$ Git commit-m'initial project version'

----------------------------------------------------------------

Note:

The GIT add command pulls the file into version control. *. C Indicates adding all c files.

Git commit-m'initial project version' indicates the comments during submission.


Now you have a git repository that actually maintains several files.


3) clone from existing warehouse:

---------------------------------------------------

$ Git clone git: // github.com/schacon/grit.git

-----------------------------------------------------------

Or

-------------------------------------------------------

$ Git clone git: // github.com/schacon/grit.git mygrit

----------------------------------------------------------------

Mygrit name the cloned database name for you

Clone from the local repository: replace git: // github.com/schacon/grit.git with the GIT repository path.


B. Gui

1) local library folder in the local file: Right click: Select git init here ----> or use git create repository here

 

 

 

A folder named. Git is displayed under the local library folder, which is a hidden folder.

2) Create the file to be added and right-click it: git add all files now

Then: git commit --> "master" can see the following interface. Enter the commit message and click OK.

 

Right-click git history to view the previous version.

Right-click to create a branch:

Then

For example, mybranch

The successfully created branch is displayed.

2) switch to the working directory clone library and select git clone

Right-click and select:

 

Select dir as the local database, and Web as the remote database

Select the corresponding folder or web and git address. You can see that there are files in the local database.

3) Right-click to modify any file:

Select git commit --> "master"

You can view the history through git history.

This is only because the tracking file is submitted locally and not submitted to the remote database.

As shown in the following figure: push to the repository

In this way, you can view the modified content in the GIT version library.

Note: This commit is submitted to the mybranch created in the branch you created. You can only right-click the repository and switch to git branch and switch to mybranch to see the modified result.

Note: git branch of the Repository cannot be under the Branch you want to submit during push. That is, when submitting a request to mybranch, git branch must switch to the master branch or another branch you have created. If mybranch is used, the push fails, because git considers mybranch To Be In checkout by default and cannot submit.

 

4) Merge the contents of mybranch into the master Branch

First, run the following command:

-----------------------------


$git diff  mybranch


--------------------------

If the GIT diff command is executed and the modification to the test Branch (mybranch) is correct, you can use the GIT merge command to merge it into the master branch:

Run the following command:

-------------------------------------

Git merge mybranch

--------------------------------------

 

In the graphical interface, switch to the mybranch branch and right-click

If you select merge, the master branch can be merged.

 

Git Initial Attempt

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.