Git remote repository details

Source: Internet
Author: User

Git remote repository details

Outline:

I. Preface

Ii. Git server Construction

3. Add remote warehouses

4. clone a repository from a remote location

V. Summary

Note: CentOS 5.5 x86_64, Git server version: git version 1.8.2.1, and Client version: git version 1.9.2.msysgit.0. Download all the software here: http://msysgit.github.io /.

I. Preface

In the previous blog, we mainly explained how to manage the Git local repository. You no longer need to manage and Back Up Files. Git is all done for you, hey! Some bloggers will say that the content you mentioned in the previous article can be implemented by SVN. Isn't Git great? Hey, what I want to say is that there must be the same features in many version controls, but we have to look at some special and practical features, today, we will show you the remote version library, a special feature of Git.

As we all know, Git is a distributed version controller. The same version library can be used on different clients. Therefore, it is necessary to have a master server. All such clients may "clone" the original version library, and the version library of each client will be the same. Therefore, a Git server is required for developers. In this way, other people can clone a copy from the Git server to their own computer, or submit their own code to the version library of the remote server, you can also pull Code submitted by others. Is it convenient? Hey, hey! Some bloggers will say that we have no more computers to build Git servers. What should we do? That's all I want to say. Because there is a website called GitHub. This website provides Git version library management. You just need to register an account on the GitHub website to get a Git remote repository for free. Isn't that amazing? Here, we would like to thank the open source and the Open Source spirit.

As we have already mentioned above, we have two methods to achieve multi-person development through Git remote Repository:

  • Build your own Git Server

  • Select open-source GitHub

I will mainly explain how to build a server here. After all, it is very easy to find a server in an enterprise. If there is no server, we will explain GitHub in detail in a later article. Now let's build our own Git server.

GitHub Tutorials:

GitHub tutorials

Git tag management details

Git branch management

Git remote repository details

Git local Repository (Repository) Details

Git server setup and Client installation

Git Overview

Ii. Git server Construction

Let's build a Git server! Actually, the Git server has already been set up in the previous article. Here we will give you a simple demonstration!


[Root @ test ~] # Rpm-ivh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
[Root @ test ~] # Yum list
[Root @ test ~] # Yum install-y git
[Root @ test ~] # Git -- version git version 1.8.2.1

Now, we have installed the Git server. It's easy!

3. Add remote warehouses
1. Added git users to run the git service.
[Root @ test ~] # Mkdir-pv/data/git mkdir: created directory '/data/git'
[Root @ test ~] # Useradd-r-d/data/git
2. Create a git repository and initialize an empty repository.
[Root @ test git] # cd/data/git/
[Root @ test git] # ls
[Root @ test git] # git init -- bare project1.git
Initialized empty Git repository in/data/git/project1.git/
[Root @ test git] # cd project1.git/
[Root @ test project1.git] # ls
Branches & #160; config & #160; description & #160; HEAD & #160; hooks & #160; info & #160; objects & #160; refs
Through the above command, Git will create a bare repository, which has no work zone. Because the Git repository on the server is for sharing, users are not allowed to log on to the server directly to modify the work zone, the Git repository on the server generally uses. git end. Then we modify the directory owner.
[Root @ test project1.git] # chown-R git. git/data/git /*
[Root @ test project1.git] # ll
Total 32
Drwxr-xr-x 2 git 4096 May 20 branches
-Rw-r -- 1 git & #160; & #160; 66 May 20 config
-Rw-r -- 1 git & #160; & #160; 73 May 20 description
-Rw-r -- 1 git & #160; & #160; 23 May 20 HEAD
Drwxr-xr-x 2 git 4096 May 20 hooks
Drwxr-xr-x 2 git 4096 May 20 info
Drwxr-xr-x 4 git 4096 May 20 objects
Drwxr-xr-x 4 git 4096 May 20 refs
3. Disable git User Logon
[Root @ test project1.git] # vim/etc/passwd
[Root @ test project1.git] # cat/etc/passwd | grep git
Git: x: 101: 105:/data/git:/usr/bin/git-shell
We modified the shell of the git user for security considerations. Modify it to/usr/bin/git-shell. In this way, git users will not be able to log on to the system, because the git-shell will automatically exit every time they log on. Now, the Git repository Initialization is complete. The following example shows how to clone a remote repository on the client ......

4. clone a repository remotely

1. The client generates the ssh logon Public Key

2. view the generated ssh Public Key

3. send the generated public key to the git server (because I can manage the git server here, I directly scp it. developers who cannot manage the git server should send the public key to the Administrator for related operations)

[Root @ test ~] # Cd/data/git/

[Root @ test git] # ls project1.git

[Root @ test git] # ls-a. & #160; .. & #160; project1.git

[Root @ test git] # mkdir. ssh

[Root @ test git] # ls project1.git

[Root @ test git] # ls-a. & #160; .. & #160; project1.git & #160;. ssh

[Root @ test git] # cd. ssh/

[Root @ test. ssh] # vim authorized_keys

Ssh-rsa Secure ++ secure + secure/henTl2euI3XsnJQ/ITr6c/q0p3wogl4e21_q2kzqs + secure/secure + kJzJSKUTKDVSwY3/+ Q = root @ CHENMINGQIAN

[Root @ test. ssh] # cat authorized_keys

Ssh-rsa Secure ++ secure + secure/henTl2euI3XsnJQ/ITr6c/q0p3wogl4e21_q2kzqs + secure/secure + kJzJSKUTKDVSwY3/+ Q = root @ CHENMINGQIAN

4. The client clones the remote warehouse to the local device.

V. Summary

Now, our remote repository management is over. In the next blog, we will focus on Git branch management. Finally, I hope you will get something better ......

Git authoritative guide PDF

Git details: click here
Git: click here

This article permanently updates the link address:

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.