`
李俊良
  • 浏览: 143792 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

git 使用

 
阅读更多

Git Server Group-level Structures

DEC 10TH, 2012 | COMMENTS

If you use a small number of git, you can use the following steps to quickly deploy a git server environment. For example, as I am now the situation to two people on assignment to Qita company to do projects, but to do something that is completely independent of the time in addition to the integration of other projects with the company code group interaction, and usually can not be free to interact with the code, alas, shit’s security, other times on my two visits.

SSH public key generation

Each need to use git server engineers, they need to generate a ssh public key into your ~ /. Ssh directory to see if a file name and file name to use. Pub named after a pair of files, the file name is usually id_dsa or id_rsa . . Pub is the public key file, another file is key. Without these files (or simply connected. Ssh directory are not), you can use the program ssh-keygen to create them, the program in the Linux / Mac systems provided by the SSH package in Windows, is included in MSysGit bag:

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/schacon/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /Users/schacon/.ssh/id_rsa.
Your public key has been saved in /Users/schacon/.ssh/id_rsa.pub.
The key fingerprint is:
43:c5:5b:5f:b1:f1:50:43:ad:20:a6:92:6a:1f:9a:3a schacon@agadorlaptop.local

It first asks you to confirm the position of saving the public key (.ssh / id_rsa), then it will let you repeat a password twice, if you do not want to enter a password when using the public key can be left blank.

Now, all users have done this step had to put their public key to your server administrator or Git (assuming the service is configured to use SSH public key mechanism). They only need to copy. Pub file contents and then e-email it. The way the public key as follows:

$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSU GPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3 Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XA t3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/En mZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbx NrRFi9wrf+M7Q== test@agadorlaptop.local

Set up the server

First, create a ‘git’ user and to create a. Ssh directory in the user home directory:

$ sudo adduser git
$ su git
$ cd
$ mkdir .ssh

Next, the developer of the SSH public key added to the user’s authorized_keys file. Suppose you received via e-mail co-existence of several public key to a temporary file. Authorized_keys file as long as they are added

$ cat /tmp/id_rsa.curtis.pub >> ~/.ssh/authorized_keys
$ cat /tmp/id_rsa.dylan.pub >> ~/.ssh/authorized_keys

Now you can use the-bare option to run git init to set an empty warehouse, which will initialize a repository does not contain a working directory.

$ cd /opt/git
$ mkdir project.git
$ cd project.git
$ git –bare init

At this time, developers can add it to remote storage, push a branch to the first version of the project was uploaded to the warehouse. It should be noted that every time you add a new project requires the host through the shell login and create a pure warehouse. We may wish to gitserver as the git user and the warehouse where the host name. If you run the host within the network, and set gitserver in the DNS to point the host, then the following commands are available.

$ cd myproject
$ git init
$ git add .
$ git commit -m ‘initial commit’
$ git remote add origin git@gitserver:/opt/git/project.git
$ git push origin master

Thus, cloning and push other people the same become very simple:

$ git clone git@gitserver:/opt/git/project.git
$ vim README
$ git commit -am ‘fix for the README file’
$ git push origin master

Using this method can be very quick to set up a small number of developers can read and write Git services.

As an extra precaution, you can use Git comes with a simple tool to git-shell git users to limit the activities associated only with Git. Make it git user login shell, then the user can not have a normal shell access to the host. To achieve this, the need to specify the user’s login shell is a git-shell, rather than bash or csh. You may have to edit / etc / passwd file

$ sudo vim /etc/passwd

In the end of the file, you should be able to find the line like this:

git:x:1000:1000::/home/git:/bin/sh

The bin / sh to / usr / bin / git-shell (or, which git-shell to see its location). Modified the way the bank is as follows:

git:x:1000:1000::/home/git:/usr/bin/git-shell

Now git user can only use SSH connection to push and get Git repository, and can not directly use the host shell. Try to log on, you will see the following information about this rejection:

$ ssh git@gitserver
fatal: What do you think I am? A shell?
Connection to gitserver closed.

via: http://www.codeweblog.com/git-server-group-level-structures/

分享到:
评论

相关推荐

    git使用教程git使用教程

    git使用教程git使用教程git使用教程git使用教程git使用教程git使用教程git使用教程git使用教程git使用教程git使用教程git使用教程git使用教程git使用教程git使用教程git使用教程git使用教程git使用教程git使用教程...

    Git使用简介.pptx

    Git 使用简介 Git 是一个版本控制系统,允许用户追踪文件的变化历史,并且能够在不同的开发分支之间进行切换和合并。本文档将对 Git 的基本概念和使用方法进行介绍,并对 Git 的分支模型进行详细的解释。 Git 的...

    git 使用详细手册

    解决冲突是Git使用中的常见问题。当多个用户修改同一部分代码时,Git无法自动合并,会提示冲突。冲突的文件会带有诸如`, `=======`, `>>>>>>>`的标记,需要手动编辑来解决冲突,然后提交更改。 此外,`git log`用于...

    git使用教程详细介绍

    Git 使用教程详细介绍 本资源是 Git 使用教程的详细介绍,涵盖了 Git 的基础知识、分支管理、服务器搭建、分布式 Git、Git 工具、自定义 Git 等多方面的内容。通过本教程,读者将了解 Git 的使用方法、版本控制的...

    Git使用手册.pdf

    Git的使用涉及多个步骤,从安装到日常操作,每个环节都有其特定的命令和流程。 首先,安装Git非常简单,可以从Git官方网站(https://git-scm.com/downloads)下载对应操作系统的版本,并按照默认设置进行安装。安装...

    Git 使用教程详解.docx

    Git 使用教程详解.docx Git 使用教程详解.docx Git 使用教程详解.docx Git 使用教程详解.docx Git 使用教程详解.docx Git 使用教程详解.docx Git 使用教程详解.docx Git 使用教程详解.docx Git 使用教程详解.docx ...

    Git使用介绍及高级技巧

    Git使用介绍及高级技巧 Git Magic.pdf

    git使用视频教程.txt

    git使用视频教程,带你一步步学会git的使用,安装、提交代码、解决冲突等等!

    git使用流程

    在本文中,我们将深入探讨“git使用流程”,包括创建代码仓库、添加文件、解决冲突以及克隆远程仓库。 一、创建代码仓库并上传本地代码 要将本地工程上传到Git仓库,首先需要初始化本地目录为Git仓库: ```bash ...

    git使用总结

    ### Git使用总结 #### 版本管理工具:Git **Git**是一款分布式版本控制系统,用于追踪计算机文件的更改,并协调由多人共同开发的项目。它最初由Linus Torvalds于2005年创建,旨在支持Linux内核的开发。与传统的...

    超级详细的GIT使用教程总结

    git使用说明超级详细的总结分类,使用mindManager完成资源分类

    git使用规范

    ### Git使用规范详解 在软件开发领域,Git作为版本控制系统的重要性不言而喻。它不仅提供了强大的代码管理功能,还能促进团队协作,提高开发效率。本文将深入解析Git的使用规范,涵盖工作流程、基本操作命令及其...

    Git使用.docx

    Git 使用指南 Git 是什么? Git 是目前世界上最先进的分布式版本控制系统。它的工作原理是 Workspace(工作区)、Index / Stage(暂存区)、Repository(仓库区或本地仓库)和 Remote(远程仓库)。 与 SVN 的...

    Git使用教程pdf

    此资源是Git官网的官方学习手册、指南,且是中文版,非常详细和明确,借此手册可以对Git从入门到深入进行系统的学习,墙裂推荐!Git的代码托管功能远强于svn,可以说是开发必备技能之一。官网下载很慢,所以此处提供...

    git使用简介ppt

    ### Git使用简介及关键知识点 #### 一、Git介绍及其特点 **Git** 是一个开源的分布式版本控制系统,被广泛应用于软件开发过程中,用于高效地管理和跟踪计算机文件的各种变动。Git 最初由 Linus Torvalds 开发,...

    git使用教程.pdf

    在学习Git使用的过程中,首先需要了解如何安装Git。大多数现代操作系统都支持通过包管理器安装Git,例如在Ubuntu上可以使用`apt-get install git`命令,在macOS上可以使用Homebrew,而在Windows上则可以使用Git for ...

    Git使用官方文档

    根据提供的信息,我们可以了解到这是一本关于Git使用的官方文档——《ProGit》,下面将对文档中的几个关键章节进行概述,并提取其中的重要知识点。 ### 一、前言 #### Preface by Scott Chacon 该部分由Scott ...

    git 使用简易指南

    Git是目前广泛使用的版本控制系统,为程序员提供了方便的代码版本管理功能。本指南将介绍Git的基本使用方法,帮助读者快速掌握Git的...以上便是git使用的简易指南,希望能帮助您快速上手Git,轻松进行代码版本的管理。

    pro_git_中文版本(Git使用教程)

    "Pro Git中文版本"是一本深入介绍Git的书籍,适合新手和有经验的开发者学习,提供了详尽的Git使用教程。以下是这本书可能涵盖的一些核心知识点: 1. **Git基础**:首先,你需要了解Git的基本概念,如工作区、暂存区...

    Git使用详细教程.docx

    版本管理工具Git的入门教程,较为详细,适合初学者阅读

Global site tag (gtag.js) - Google Analytics