Explain the use of Git version system in Visual Studio (text)

Source: Internet
Author: User
Tags git commands

Many people already use git (or are moving to git), on the github.com, also see a lot of domestic students open source projects, very good. But the tutorials don't seem to be much, so I wrote an article in my own Open-source project hosting (Https://github.com/wojilu/wojilu).

This tutorial is expected to be available without any version of the basis of the novice can also master, so more details, improper, welcome correction.

Part I: Installing GIT development tools

If you want to use Git for versioning, it's perfectly enough to use the Git command-line tool, and graphical tools, whether Git extentions or tortoisegit, are just encapsulation of the command line. As far as functionality is concerned, the command line can do all that they can, but the command line can do it, they don't have to. Command line more original, true colors, across the platform, Isidam. It is recommended that you familiarize yourself with the Git command-line tool.

But the graphical tool also has its own merit, is intuitive. The following recommended combination scenarios are:

git command line (cygwin) + git Extensions + git Source control Provider

--This combination can completely solve Chinese file problems (including Chinese filename, directory name, and normal display in GitHub).

1 Install Cygwin command line tool

Installation tutorials See http://gotgit.github.com/gotgithub/10-appendix/030-install-on-windows-cygwin.html

Software to install during installation:

Git-completion: Provides automatic completion of GIT commands. Installing the package automatically installs the dependent Bash-completion software package.

OPENSSH:SSH client that provides Git access to the version library of the SSH protocol.

Vim: Is the default editor for Git.

2 Install git extensions

Role

Git extensions must rely on command-line tools, so the second installation.

It is not only available after installation, but also automatically adds plug-ins to VS, which can be very intuitive and easy to operate in vs.

"Installation Method"

Download URL: http://code.google.com/p/gitextensions/downloads/list Select the version of Gitextensions226setupcomplete.msi with complete, which integrates the KDIFF3 tool.

After downloading, double-click Install, all the way next, remember to check msysgit and KDIFF3 in the middle.

GIT extensions has a comprehensive tutorial since it was installed.

Configuration

We know that there are currently two types of git command-line tools, one is the Cygwin command line, one is the msysgit command line, git extensions can configure which command-line tool to use, the following figure, we choose to use Cygwin instead of msysgit

The first one is: "User runs Git's command"

The second is: Global configuration file, please click the "Change Home" button, the directory to the Cygwin directory.

In addition, GIT extensions will change the Cygwin default editor VI to its own, and you can change it back in the global settings.

Supplemental 1:git extensions configuration files are placed in the registry, if uninstalled, these configurations are still retained, you can install the problem again, you can check the registry for related configuration items, whether there is a problem.

Add 2: During the installation of Git extensions, we checked the Msysgit, now installed, you can uninstall Msysgit, but can also keep, because msysgit installation directory with git all the commands of the help document.

3 Install Git Source control Provider

Role

Excerpt from: http://blog.csdn.net/wojilu/article/details/6976230

Git Source control Provider is an extension of VS, but must rely on git extensions, so a third installation, which can display file status, display file history, and so on, makes it easier to manipulate files in vs.

Project Web site: http://gitscc.codeplex.com/

Source: Https://github.com/yysun/Git-Source-Control-Provider

Video Tutorials: www.youtube.com/watch?v=efS0kKvfi6k

"Installation Method"

In the VS menu, tap the Extension Manager for tools

Then search for git online and the first result is Git Source control Provider and click "Download"

Then click the "Options" option on the VS menu, expand Source Control on the left, select "Git Provider" in the "Current source code management plug-in" on the right, and click "OK"

When Git Source control Provider is enabled, all files display a status icon. You can right-click on the file and go to the Git menu for action.

The following is a new test project to demonstrate how to visualize the Git version library in vs. If you complete the basics, you can participate in the actual GitHub project, such as "I record the development framework" and "I record the integrated system of Web sites (integrated"sns/portal cms/forums/blogs/albums/Weibo/wiki"applications such as Internet products)" has been hosted to GitHub, the URL is https://github.com/wojilu/wojilu.

First, create a version library

Create a new item with VS, then click Initialize New Repository on the Git menu

Pop-up window allows you to select a directory to be included in GIT version management--

After initialization, a. Git hidden folder appears in the project directory, which is the Git version library.

All files in one directory with Git are now within the scope of this version library.

Now that you are in this directory, you can execute the git command.

For example, the following is the direct operation of GIT commands in the GIT Command line window, using the command line to complete all git versioning operations.

But our section focuses on how to visualize git in VS, and not on command-line management for the time being.

Ii. submitting files to the version library

Only by incorporating the files from the project into the repository can we enjoy the benefits of the version management system, such as browsing the history version, switching branches, etc...

1 First, please close vs and reopen. If you do not reopen, the plug-in Git Source control cannot monitor file status.

After reopening, the file displays the status symbol: the "+" plus sign, which indicates that the status of these files is "not yet included in the version library", is required for you to add.

You can submit by clicking "Commit" on the "Git" menu

The following submission window appears

We see that there are a lot of files to submit here, but in fact, a lot of files are vs automatically generated temporary files, and the project content is not related to, should not be included in version management, such as ***.suo files, at this time, we need to set these files to "need to ignore files", let git ignore them

2 setting ignores files

Please close the Commit window above and click the command "Edit. Gitignore" In the VS Menu "Git"

An edit window appears that ignores the file, and the content area on the left side of the window is currently blank and has no content.

However, the right side lists some common files that need to be ignored (default), click the "Add Default Override" button on the lower right side, add the content you want to ignore to the left content area, and click "Save".

Then open the folder and you will see a file named. Gitignore in the project, which is what you just saved.

3) Submit step A (join registers)

Click "Commit" in the menu "Git" again, and now the submission window shows a significant reduction in the file that needs to be submitted, such as ***.suo files that have been ignored by git.

If you click the "submit" command directly, the following prompt will appear, meaning "there is no file in the registers." Need to be staged and submit all files immediately. ”

What does this sentence mean? This involves the concept of a registers (stage) of Git, where there are three saved files in git:

1 working directory, that is, you operate on the hard disk of these directories and files;

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.