最新搭建GIT服务器仓库
新开了一个项目,现在需要将代码放在公司GIT服务器上面。所以这里需要了一些问题。。记录一下。
因为原来公司这边的服务器的git用户都是创建好的。这里没有创建。需要的可以看看:http://www.cnblogs.com/zhoug2020/p/5789041.html。这个博客。
我是直接从创建仓库那里开始了。。通过查找搭建GIT服务器仓库的教程,但是教程有很多问题。导致一直失败。所以这里就写一份本人自己的一些流程方法,供大家参考。
1.进入到git服务器。(比如我这边进入是 执行命令: ssh username@192.111.111.111)..username是配置的用户名。再写上自己的git服务器ip。这里会提示输入密码。
2.进到git服务器后,创建工程的文件夹。执行命令:mkdir ProjectName。
3.进入到创建的工程文件夹。执行命令:cd ProjectName。
4.初始化一个git仓库。。
4.1。如果不执行 touch Readme、git add Readme的操作的话。不管是拉取还是其他操作都会出现"This operation must be run in a work tree"错误。网上很多教程是没有这个步骤的,。被坑惨了。
//执行下方4个命令
touch Readme
//网上还有 git --bare init的方法。如果执行git --bare init初始化的话。在git add Readme这部会提示“This operation must be run in a work tree”错误。
//如果不执行 touch Readme、git add Readme的操作的话。不管是拉取还是其他操作都会出现"This operation must be run in a work tree"错误。网上很多教程是没有这个步骤的,。被坑惨了。
git init
git add Readme
git commit -m 'initial commit' Readme
5.进入到git。修改配置文件。执行命令:cd .git(要在ProjectName目录下执行)
6.修改配置文件。config。。执行命令:vim config
7.添加相关配置信息。在config文件内添加:
[receive]
denyCurrentBranch = ignore
7.1。如果不添加配置信息的话。会在push的时候出现错误:
//推送被拒绝然后输出的错误信息
[remote rejected] master -> master (branch is currently checked out)
remote: error: refusing to update checked out branch: refs/heads/master
remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.
remote: error:
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
remote: error: its current branch; however, this is not recommended unless you
remote: error: arranged to update its work tree to match what you pushed in some
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, set
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
To git@192.168..X:/var/git.server/.../web
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'git@192.168.1.X:/var/git.server/.../web'
8.创建完git仓库了。。这时候要给用户赋权限。不然的话,不能对他进行操作。执行命令:chown -R username .git(这个命令是在ProjectName文件夹的路径后执行的。注意.git的路径是不是对的。)
9.完成整个步骤。这是你通过clone等命令或者使用SourceTree工具将git仓库保存到本地后,在相应文件夹添加或者修改内容后就能push上去了。
PS:git是一个很好的源码管理工具,公司内部的话,搭建服务器的git仓库是很有必要的。所以这次的搭建仓库成功还是很有成就感的。哈。其实主要的就3个地方要注意:
1.权限有没有赋给用户
2.Readme文件有没有添加。
3.config配置文件有没有配置对。
谢谢。
最新搭建GIT服务器仓库的更多相关文章
- 不搭建git服务器对git仓库进行局域网内共享多人合作开发项目
有时候在一个临时局域网内没有搭建git服务器,但是又想多人开发一个项目,此时只要每个人电脑安装有git客户端,参考一下方法即可尝试建一个本地化的远程仓库进行多人开发工作. 远程仓库通常只是一个裸仓库( ...
- Git服务器仓库的搭建和客户端使用方法
环境说明: 1.fedora21 桌面系统 2.已经配置好yum仓库 一.安装git # yum install git 1.1 创建git用户 创建git账户并登录,直接指定用户目录到/home ...
- (转)初学Git及简单搭建git服务器和客户端
终于搞定,mac自己作为git服务器,mac也是客户端,如何免登 从另外一个linux服务器的上传公钥得到提示 ssh-copy-id -i ~/.ssh/id_rsa.pub git@192.168 ...
- 搭建Git服务器及本机克隆提交
前文 Git是什么? Git是目前世界上最先进的分布式版本控制系统. SVN与Git的最主要的区别? SVN是集中式版本控制系统,版本库是集中放在中央服务器的,而干活的时候,用的都是自己的电脑,所以首 ...
- 搭建Git服务器
在远程仓库一节中,我们讲了远程仓库实际上和本地仓库没啥不同,纯粹为了7x24小时开机并交换大家的修改. GitHub就是一个免费托管开源代码的远程仓库.但是对于某些视源代码如生命的商业公司来说,既不想 ...
- Git学习笔记(10)——搭建Git服务器
本文主要记录了Git服务器的搭建,以及一些其他的配置,和最后的小总结. Git远程仓库服务器 其实远程仓库和本地仓库没啥不同,远程仓库只是每天24小时开机为大家服务,所以叫做服务器.我们完全可以把自己 ...
- centos 搭建git服务器
centos 6搭建git服务器 安装 rpm -ivh http://mirrors.aliyun.com/epel/epel-release-latest-6.noarch.rpm yum ins ...
- 如何在服务器上搭建git服务器
参考文章: http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/00137583770 ...
- 使用Gitosis搭建Git服务器
使用Gitosis搭建Git服务器 作者: JeremyWei | 可以转载, 但必须以超链接形式标明文章原始出处和作者信息及版权声明 网址: http://weizhifeng.net/build- ...
随机推荐
- 怎么利用SQL语句查询数据库中具体某个字段的重复行
select * from [tablename] group by SeriNohaving count(SeriNo)<>1
- poj1001 Exponentiation
Description Problems involving the computation of exact values of very large magnitude and precision ...
- Python xlsx 读取
代码示例 #!/usr/bin/env python import xlrd, sys, re, os workbook = xlrd.open_workbook( sys.argv[1] )for ...
- POJ 2240 Arbitrage (求负环)
Arbitrage 题目链接: http://acm.hust.edu.cn/vjudge/contest/122685#problem/I Description Arbitrage is the ...
- HDU 5775 Bubble Sort (线段树)
Bubble Sort 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5775 Description P is a permutation of t ...
- HDU 5752 Sqrt Bo (数论)
Sqrt Bo 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5752 Description Let's define the function f ...
- HDU2079选课时间(母函数)
母函数的简单应用http://acm.hdu.edu.cn/showproblem.php?pid=2079 介绍见另一篇随笔HDU1028Ignatius and the Princess III( ...
- SQL 错误1418
1.一个或多个服务器网络地址缺少完全限定域名(FQDN).为每个服务器指定FQDN,然后再次单击“开始镜像”.2.服务器网络地址"TCP://primary.test.com:5022&qu ...
- vs2012下安装VisualHG
好久没写东西了.懒了.最近开发用到HG,记录一下.希望对用这个的有用 http://visualhg.codeplex.com/ 这里下载 VisualHG 安装完默认情况下 源代码管理出不来Visu ...
- MEF 编程指南(二):定义可组合部件和契约
可组合部件(Composable Parts) 在 MEF 内部可组合部件是一个可组合单元.可组合部件导出其他可组合部件需要的服务,并且从其他可组合部件导入服务.在 MEF 编程模型中,可组合部件 ...