How to Build and use Git servers in Ubuntu

Source: Internet
Author: User

How to Build and use Git servers in Ubuntu

I. Preface

Git is a free and open-source distributed version control system for effective and high-speed processing of project version management from very small to very large. In normal project development, we use Git for version control.

Features of Git:

From the perspective of general developers, git has the following functions:

1. Clone the database (including code and version information) from the server to the single machine.
2. Create a branch on your machine and modify the code.
3. Submit code on the Branch created on the standalone.
4. merge branches on a single machine.
5. Create a new branch, run the latest version of the Code fetch on the server, and merge the Code with your main branch.
6. Generate a patch and send it to the primary developer.
7. Check the feedback from the primary developer. If the primary developer finds that there is a conflict between two general developers (they can work together to solve the conflict), they will be asked to resolve the conflict first, then one of them submits the request. If the primary developer can resolve the issue by themselves or there is no conflict, it will pass.
8. Generally, developers can use the pull command to resolve conflicts. After resolving the conflicts, they can submit patches to the primary developers.

From the perspective of the primary developer (assuming that the primary developer does not need to develop code), git has the following features:

1. view the mail or other methods to view the submission status of general developers.
2. Install patches to resolve conflicts (you can resolve the conflicts by yourself or ask developers to resolve the issues before resubmitting them. If it is an open-source project, you need to decide which patches are useful and which ones are not needed ).
3. submit the results to the public server and notify all developers. There are many ways to build a Git server on the Internet. This article focuses on how to use and use the Git server after it is built, such as permission setting and cross-platform usage.

PS: For the establishment of Git server, this article provides the following links for your reference.

Ubuntu perfectly installs and builds a 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

Share practical GitHub tutorials

2. Git server operations and User Guide

1. Install git in Ubuntu and use the git Server

Enter the sudo apt-get install git command on the terminal to install git

The following steps take hesonglin @ master as an example.

You can enter the Your Name and Email at will to identify git.

Create a folder, for example:

Enter the git init command to initialize the folder as a git repository (empty repository)

Enter the ssh-keygen-t rsa command to generate the ssh Public Key (press Enter when a pause occurs)

A. ssh folder is generated under the main folder directory (press Ctrl + H to display it if no folder exists)

Create a new gitadmin directory under the repository directory on the Virtual Machine to store the gitosis-admin.git repository such:

Clone the gitosis-admin.git Repository from the Git server (the git@218.108.45.14 is the Git server that I built, instead of the Git server you built)

If Clone is correct, the following information is displayed:

After cloning, a gitosis. conf configuration file and a keydir directory are generated. Gitosis. conf is used to configure the user's permission information. keydir is used to store the ssh public key file (generally "user name. pub "name, gitosis. the same user name must be used in the conf configuration file.

Generate the id_rsa.pub public key file in the corresponding. ssh folder on the machine, name it as a hesonglin@master.pub by user name, and copy it to the keydir directory

Edit the gitosis. conf file and Set permissions.

Add the local user name (such as hesonglin @ master) and grant permissions

These configuration modifications are only made locally and must be pushed to the server for the modifications to take effect.

The above git add. and git commit-am "add a user" are saved and submitted to the local

Git push origin master means to push the above changes to the Git Server

The following message is displayed when the push is successful.

So far, the Git server has the same information as the keydir and gitosis. conf configured above.

For example, I have created a teamwork. Git repository on the git server to manage projects, for example:

Now we can clone teamwork. Git from the git server on the local machine and push it to the git server after modification.

First, create a folder myrepository on the local machine.

Go to myrepository to clone teamwork. git

Shows how to obtain the teamwork. git repository.

Create a readme file in the local teamwork. git repository, and then submit and push the file.

When the teamwork. Git repository is updated on the git server, you can use the git pull command on the local machine to obtain the latest data version (note that the data must be in the teamwork directory)

In this case, the teamwork. git repository on the local machine has the latest data pushed by other development machines (if the latest data is pushed by other development machines ).

Now, this virtual machine can perform pull and push operations from the Git server.

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

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.