In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces how to customize the use of git, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
There are many places where Git can be configured.
For example, letting Git display colors makes the command output look more eye-catching:
$git config-global color.ui true
In this way, Git displays different colors appropriately, such as the git status command:
The file name will be colored.
We'll also show you later how to better configure Git to make your work more efficient.
Set up git server
GitHub is a remote repository that hosts open source code for free. But for some commercial companies that see source code such as life, they do not want to release the source code and are reluctant to pay GitHub protection fees, so they can only build their own Git server to use as a private warehouse.
To set up a Git server, you need to prepare a machine running Linux, and Ubuntu or Debian is highly recommended so that the installation can be completed with a few simple apt commands.
Assuming that you already have a user account with sudo permission, the installation will begin.
Step 1: install git:
$sudo apt-get install git
The second step is to create a git user to run the git service:
$sudo adduser git
Step 3: create a certificate login:
Collect the public keys of all users who need to log in, which is their own id_rsa.pub file, and import all the public keys into the / home/git/.ssh/authorized_keys file, one line at a time.
Step 4, initialize the Git repository:
First select a directory as the Git repository, assuming / srv/sample.git, and enter the command in the / srv directory:
$sudo git init-bare sample.git
Git creates a naked warehouse, which does not have a workspace, because the Git repository on the server is purely for sharing, so users are not allowed to log in directly to the server to change the workspace, and the Git warehouse on the server usually ends with .git. Then, change owner to git:
$sudo chown-R git:git sample.git
Step 5: disable shell login:
For security reasons, the git user created in step 2 is not allowed to log in to shell, which can be done by editing the / etc/passwd file. Find a line similar to the following:
Git:x:1001:1001:,:/home/git:/bin/bash
Change to:
Git:x:1001:1001:,:/home/git:/usr/bin/git-shell
In this way, git users can normally use git through ssh, but cannot log in to shell because the git-shell we specified for git users automatically logs out each time they log in.
Step 6, clone the remote repository:
You can now clone the remote repository with the git clone command and run it on their respective computers:
$git clone git@server:/srv/sample.gitCloning into 'sample'...warning: You appear to have cloned an empty repository.
The rest of the push is simple.
Manage public key
If the team is small, it is possible to collect everyone's public key and put it in the / home/git/.ssh/authorized_keys file on the server. If there are hundreds of people on the team, you can't play like this, and you can use Gitosis to manage the public key.
Here we will not introduce how to play Gitosis, hundreds of people's teams are basically in the top 500s, I believe it is not a problem to find a high-level Linux administrator.
Administrative authority
Many companies that regard not only source code as life, but also employees as thieves, will set up a complete set of permission control in the version control system, and whether everyone has read and write access will be accurate to each branch or even under each directory. Because Git is developed for Linux source code hosting, Git also inherits the spirit of the open source community and does not support permission control. However, because Git supports hook, you can write a series of scripts on the server side to control operations such as commit to achieve the purpose of permission control. Gitolite is this tool.
We are not going to introduce Gitolite here, so don't waste your limited life in the rights struggle.
Thank you for reading this article carefully. I hope the article "how to customize the use of git" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.