Git installation Use Notes

Source: Internet
Author: User
Tags git workflow ssl certificate

This article is mainly about documenting the process of installing GIT on the Windows platform and the simple use of git.

Describe the installation requirements first:

· Both the client and server side operating systems are Windows.

· The client should be able to access the repository via HTTP.

· Whether to take out files or send files, you need to verify your identity (enter your account password).

Below are the installation steps:

Step 1: Install Git for Windows

In a Windows environment using GIT, you can use Msysgit (git for Windows), and the version I installed is v1.7.4. Once installed, there will be a menu in the assembly: Git with two programs: Git GUI and git Bash. The former is the graphical operation interface, the latter is the command Line window. The default installation directory for Git is C:\Program files\git.

Since I want the client to be able to access the repository through the HTTP protocol, it is also possible to copy the Bin\libiconv2.dll from the Git installation directory under libexec\git-core\ under the installation directory. Without this action, HTTP-Internal Server error messages will appear when the repository is accessed via HTTP in the future. As shown in the following:

Step 2: Install Apache HTTP Server

To provide access to HTTP, you can take advantage of Apache http Server. The version I installed is Apache 2.2.19 (including OpenSSL).

After installing Apache, modify the httpd.conf so thatit uses 8080 port, so that you don't have to grab port with IIS.

Next, the same is to modify the httpd.conf. Locate the <directory> tab and confirm that it is set up as follows:

<directory/>

Options FollowSymLinks

AllowOverride None

Order Deny,allow

Allow from all

</directory>

Then add the following text to the last side of the httpd.conf:

#Set this to the root folder containing your Git repositories.

# Git where your repository is placed

SETENV Git_project_root D:/gitrepos

# Set this to export all projects by default,

# Git'll only publish those repositories that contain a

# file named "Git-daemon-export-ok"

# All repositories in this directory can be accessed via HTTP (s)

SETENV Git_http_export_all

# Route specific URLS matching this regular expression to the Git HTTP server.

# enables Apache to direct git-related URLs to Git's HTTP handlers

Scriptaliasmatch \

"(? x) ^/(. *) (HEAD | \

Info/refs | \

objects/(info/[^/]+ | \

[0-9a-f] {2}/[0-9a-f]{38} | \

Pack/pack-[0-9a-f]{40}\. (PACK|IDX)) | \

git-(upload|receive)-pack)) $ "\

"C:/Program Files/git/libexec/git-core/git-http-backend.exe/$1″

<location/>

AuthType Basic

AuthName "GIT Repository"

AuthUserFile "D:/GITREPOS/HTPASSWD"

Require Valid-user

</Location>

The first instruction is to tell Git where your repository is placed, and the second instruction indicates that all repositories in that directory can be accessed via HTTP (s). The third instruction is an HTTP handler that enables Apache to direct git-related URLs to git. Note: If your Windows system is 64-bit, inside the C:/Program files/.... It's going to change. The final <Location> section sets the authentication rules for the virtual root path "/", D:/gitrepos/htpassword is the account password file.

After you complete the above modifications, restart the Apache HTTP service.

Note: If you want to use a URL that starts with http://my-server/git/* in the future by using the remote access repository, you can change the Scriptaliasmatch directive to "(? x) ^/git/(. * * (HEAD | \ .......”

Step 3: Create a version repository

A test repository is established here to confirm that the client can take out the file via the HTTP protocol. The steps are as follows:

1 Open Git Bash Command Column window: Start > Programs > Git > Git bash.

2 Enter the following command to create an empty repository (the ' $ ' symbol is a prompt character without input):
$ CD D:/gitrepos
$ git init MyProject

Reference:

The git init command for this example builds a hidden directory named ".git" in the MyProject directory, and the control files that Git uses to manage the version are all here. MyProject This directory itself is the working directory, you can add files or subdirectories in this directory.

Note: You should use the git init–bare command when you first build a repository that allows multiple people to share. Add the –bare parameter, which means to create a "pure" repository, which does not include any working copy (working copy) files, but only version control-related files.

Note: The first level of subdirectories under the repository's root directory (here is D:\GitRepos) does not have to be built into a repository. We can also create a simple subdirectory under it, and then build the repository under each subdirectory. For example:

D:\GitRepos

+–projects

+–prja (Version Library)

+–PRJB (Version Library)

+–notes

+–dotnet (Version Library)

In that case, we can then access the repository using a URL similar to "http://my-server/projects/prja".

Step 4: Remove the Repository

The more correct way to say this is to copy the Repository (clone) back to your home (native). Open the Git Bash window, switch to the directory where you plan to store the native repository, and then use Git clone to pull the archive back. The instructions are as follows:

$ CD D:/work

$ git clone http://localhost:8080/MyProject

You should then be asked to enter your account number and password, and if you enter it correctly, you can retrieve the library. Reference:

When you use the git clone command, the URL can also include the user account name, for example:

$ git clone http://[email protected]:8080/myproject

If the remote repository you want to copy is not empty, Git compresses the file and then transmits it, and displays the progress of the compression on the screen, such as:

Next

Follow-up job, is in the local working directory for the daily file modification and version submission program.

Git Basic Workflow

1 Build a shared repository.

2 Copy the repository on the remote host to the local computer.

3 Modify the working copy of this machine and submit it.

4 pushes the submitted file to the repository of the remote host.

Here's an example:

1. Create a shared repository

CD D:/gitrepos/projects/myprojecta

Git init–bare
2. Copy the repository on the remote host to the native

git clone Http://my-server:8080/Projects/MyProjectA

If your Git server supports the https://contract, the instructions for copying the repository will look something like this:

git clone Https://my-server/Projects/MyProjectA

An error occurred while copying the repository with the https://contract:

ERROR:SSL certificate problem, verify the CA cert is OK. Details:

Error:14090086:ssl routines:SSL3_GET_SERVER_CERTIFICATE:certificate Verify Faile

D while accessing https://localhost/Projects/test/info/refs

Fatal:http request failed
You can try the following directives to resolve:

Git Config–global http.sslverify false
In addition, you can specify the account password directly when copying, for example:

git clone https://michael:[email protected]/projects/myprojecta
If this "remote host" is the native that you are currently working on, that is, to replicate another repository on the same machine, you can use file://. For example:

git clone File://d:/GitRepos/Projects/MyProjectA
It is also possible to add file://or write file:///(three slashes).

3. Modify the working copy of this machine and submit

git Add.

Git commit-m "text on Commit"

4. Push the submitted files to the repository of the remote host

Git push Origin Master

One of the push representatives is going to push the changes to the remote server; Origin represents this local repository at the source of the remote server, and you can find this far-end "origin" from the. git\config file of the local repository; the final parameter, master, represents mast ER branch.

So the meaning of the above instruction, in a more precise interpretation, is to push all changes to the master branch of the machine to the master branch of the remote host.

If you do not specify a master branch, write only this:

Git push origin

Indicates that you want to push changes to all branches of this machine to the corresponding branch of the remote host.

To push native changes to other branches of the remote repository, such as feature101, you can enter directives:

Git push Origin feature101
Other developers who want to get the latest files can execute the git pull command under their local repository's directory.

The above is probably the simplest and most basic git workflow.

Git installation Use Notes

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.