2019独角兽企业重金招聘Python工程师标准>>>
通过gitolite架设git仓库
第一步:在root用户下做如下事情
adduser --system --shell /bin/bash --group git
// 创建专用账号git,所有用户都用此账号访问git库
正在添加系统用户"git" (UID 120)...
正在添加新组"git" (GID 126)...
正在将新用户"git" (UID 120)添加到组"git"...
创建主目录"/home/git"...
第二步: sudo passwd git
输入新的 UNIX 密码:
重新输入新的 UNIX 密码:
passwd:已成功更新密码
exit //退出root用户
第三步:进入git用户
su git
密码:
第四步:创建
$mkdir -p /home/git/bin/gitolite/share/gitolite/conf/ /home/git/bin/gitolite/share/gitolite/hooks/
第五步:下载gitolite
$ git clone git://github.com/ossxp-com/gitolite.git
Initialized empty Git repository in /home/git/gitolite/.git/
remote: Counting objects: 6194, done.
remote: Compressing objects: 100% (1942/1942), done.
remote: Total 6194 (delta 4324), reused 6010 (delta 4186)
Receiving objects: 100% (6194/6194), 1.42 MiB | 281 KiB/s, done.
Resolving deltas: 100% (4324/4324), done.
第六步:采用源代码方式安装gitolite
到gitolite源码所在位置, 上面clone下来的目录/gitolite/src/执行下面的命令
cd gitolite/src
$./gl-system-install /home/git/bin/gitolite /home/git/bin/gitolite/share/gitolite/conf/ /home/git/bin/gitolite/share/gitolite/hooks/
***** WARNING *****
gl-setup is not in your $PATH.
Since gl-setup MUST be run from the PATH (and not as src/gl-setup or
such), you must fix this before running gl-setup. Just add
PATH=/home/git/bin/gitolite:$PATH
to the end of your bashrc or similar file. You can even simply do that
manually each time you log in and want to run a gitolite command.
第七步:用gitolite创建仓库编辑/home/git/bin/gitolite/gl-setup
vim /home/git/bin/gitolite/gl-setup
把GL_PACKAGE_CONF变量改成上面安装gitolite的配置目录,如:
GL_PACKAGE_CONF=/home/git/bin/gitolite/share/gitolite/conf/
// 否则会打开一个空的~/.gitolite.rc,就不知道该如何往里写配置信息了
// 因为gl-system-install有问题,所以安装以后还要手工改安装目录中的这个文件gl-setup,
第八步:加入系统的环境变量
echo "PATH=/home/git/bin/gitolite:$PATH" >> ~/.bashrc
source ~/.bashrc
//每次修改.bashrc后,使用source ~/.bashrc 是修改立即生效
第九步:产生管理员的密钥在用户下
例如:我要用aa账户:
在aa账户的根目录下执行:ssh-keygen
就会在根目录下产生.ssh 目录 下面有:id_rsa id_rsa.pub
将id_rsa.pub拷贝到git用户的的根目录下:
scp .ssh/id_rsa.pub git@localhost :~/
第十步:在git 用户下:
将id_rsa.pub 命名为aa.pub
mv id_rsa.pub aa.pub
第十一步:在home/git/bin/gitolite/
$ ./gl-setup ~/aa.pub
//这里提供的公钥是作为管理员的
-- 编辑自动打开的.gitolite.rc文件:
--- 一定要修改$GL_PACKAGE_HOOKS,改成gl-system-install指定的hook目录即/home/git/bin/gitolite/share/gitolite/hooks
-- .gitolite.rc编辑完成后保存退出,继续自动执行:
creating gitolite-admin...
Initialized empty Git repository in /home/git/repositories/gitolite-admin.git/
creating testing...
Initialized empty Git repository in /home/git/repositories/testing.git/
[master (root-commit) 07c5b91] gl-setup ../../deovo.pub
2 files changed, 26 insertions(+), 0 deletions(-)
create mode 100644 conf/gitolite.conf
create mode 100644 keydir/deovo.pub
现在就可以在aa用户下clone一份gitolite-admin 仓库来管理代码和用户
git clone [email protected]:gitolite-admin.git
Initialized empty Git repository in /home/deovo/share/gitolite-admin/.git/
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (6/6), done.
git clone [email protected]:testing.git
Initialized empty Git repository in /home/deovo/share/testing/.git/
warning: You appear to have cloned an empty repository.
//这是个空的代码仓库包
cd testing/
vi aa.txt
//输入一些内容保存退出
git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add
#
# aa.txt
nothing added to commit but untracked files present (use "git add" to track)
git add -A .
git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached
#
# new file: aa.txt
#
git commit -m "test1"
[master (root-commit) 74e0d36] test1
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 aa.txt
git push origin//第一次需要用git push origin master
Counting objects: 3, done.
Delta compression using up to 16 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 375 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
remote: *** hooks.mailinglist is not set so no email will be sent
remote: *** for refs/heads/master update 0000000000000000000000000000000000000000->74e0d366935e1289764cf780c486bdbfc1966f98
To [email protected]:testing.git
* [new branch] master -> master
git log
现在将一个代码用git 管理起来
首先有一套代码
例如名字叫ics
1.将kernel u-boot out clean掉make clean
2.代码中会包含一些.git /.gitnore=.git* /.svn /.svn*
3. find . -name “.git ” -type -d找到后删除 rm -Rf ******
4. find . -name “.git*” -type f
5. find . -name “.git*” -type f -delete -print
6. find . -name “.svn” -type f
7. find . -name “.svn*” -type f
在gitolite-admin/conf/gitolite.conf
添加repo ics
RW+ = @admin
R = @all
git status
git add -A .
git commit -m “111111”
git push origin
在ics代码中
git init
git remote add origin git@localhost :ics.git
git add .
git commit -m “init ics”
git push origin master(因为第一次要加master)
之后就可以在aa用户上clone 管理好的代码了
git clone git@localhost :ics.git