Ubuntu git使用(一)git服务器的配置
来源:互联网 发布:淘宝女鞋图片 编辑:程序博客网 时间:2024/06/12 00:02
前言
作为程序猿这么长时间了,终于从windows转到了Linux,我选择了现在最为流行的Ubuntu。当然开发环境就得重新配置了,这篇博客就从git的服务器配置开始吧,虽然公司用的是svn,但对于长期混迹于github的人来说,对git也不可能陌生,而且android studio对git的支持也非常强大。下面就介绍一下git服务器的配置,当然配置git服务器需要一台运行Linux的机器,推荐大家用ubuntu。
内容
- 安装git,在ubuntu可以很简单的用apt-get安装,用下面的命令:
cfp@cfp:~$ sudo apt-get install git
2.创建一个git的用户:
cfp@cfp:~$ sudo adduser git
3.初始化一个仓库,在/srv目录下,因为在服务器上没必要显示工作空间,需要用–bare参数建一个裸的的仓库
cfp@cfp:/srv~$ sudo git --bare init code.git
第三步,创建证书登录:
4.收集所有需要登录的用户的公钥,就是他们自己的id_rsa.pub文件,把所 有公钥导入到/home/git/.ssh/authorized_keys文件里,一行一个。
5.修改仓库的拥有者为git
cfp@cfp:/srv$ sudo chown -R git:git code.git
6.禁用shell登陆,在/etc/passwd文件中将
git:x:1001:1001:,,,:/home/git:/bin/bash
改为:
git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell
7.验证一下是否成功, clone一下建的空仓库
cfp@cfp:~/sample$ git clone git@localhost:/srv/code.gitCloning into 'code'...git@localhost's password: warning: You appear to have cloned an empty repository.Checking connectivity... done.cfp@cfp:~/sample$
成功克隆!
8.建一个自己的项目,提交到服务器上:
cfp@cfp:~/sample$ mkdir project
创建一个hello文件
vi hello.txt
git init
git add .
git commit -m "init"
添加一个远程仓库:
git remote add origin git@localhost:/srv/code.git
推送项目到服务器:
git push origin master
大功告成!
补充:1.因为我的ubuntu默认有ssh服务器,并且已经启动,检查一下:
cfp@cfp:~/sample$ ps -e | grep ssh 1048 ? 00:00:00 sshd
确实已经启动
2.确定自己的git的中做了配置,生成了ssh 的公钥
0 0
- Ubuntu git使用(一)git服务器的配置
- ubuntu下git服务器的简单配置
- ubuntu上配置git服务器
- ubuntu上配置git服务器
- ubuntu上配置git服务器
- ubuntu上配置git服务器
- ubuntu上配置git服务器
- ubuntu上配置git服务器
- ubuntu上配置git服务器
- ubuntu上配置git服务器
- ubuntu上配置git服务器
- ubuntu上配置git服务器
- ubuntu上配置git服务器
- ubuntu下git服务器配置
- Ubuntu 12.04 git 服务器 配置
- ubuntu配置git私人服务器
- Git(一)、Git的安装、使用
- git服务器的配置
- iOS多线程的初步研究-- NSTimer
- hdu1159 (简单dp)
- Servlet 与 JSP 核心编程(第二卷)
- 使用Eclipse构建Maven项目 (step-by-step)
- 通过添加dns加速访问app store
- Ubuntu git使用(一)git服务器的配置
- 小Y的炮 cannon题解
- UITextView汉字光标问题
- 堆内存和栈内存详解
- Java NIO原理图文分析及代码实现
- 为什么Python中没有Switch/Case语句?
- autoreleasing的用法介绍
- 转个博客园的jsonp,说的很透彻
- Python中easy_install安装