NO.A.0004——Git私有服务器部署/makefile方式/本地与Git服务器代码交换
远程仓库实际上和本地仓库没啥不同,纯粹为了7x24小时开机并交换大家的修改。GitHub就是一个免费托管开源代码的远程仓库。但是对于某些视源代码如生命的商业公司来说,既不想公开源代码,又舍不得给GitHub交保护费,那就只能自己搭建一台Git服务器作为私有仓库使用。
1、环境准备:
[root@localhost ~]# yum -y install curl curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel
>gcc gcc-c++ autoconf perl-ExtUtils-MakeMaker package
Installed:
expat-devel.x86_64 0:2.1.0-12.el7 gcc.x86_64 0:4.8.5-44.el7
gcc-c++.x86_64 0:4.8.5-44.el7 gettext-devel.x86_64 0:0.19.8.1-3.el7
libcurl-devel.x86_64 0:7.29.0-59.el7_9.1
openssl-devel.x86_64 1:1.0.2k-19.el7 zlib-devel.x86_64 0:1.2.7-18.el7
Dependency Installed:
cpp.x86_64 0:4.8.5-44.el7 gettext-common-devel.noarch 0:0.19.8.1-3.el7
git.x86_64 0:1.8.3.1-23.el7_8 glibc-devel.x86_64 0:2.17-317.el7
glibc-headers.x86_64 0:2.17-317.el7 kernel-headers.x86_64 0:3.10.0-1160.6.1.el7
keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.15.1-50.el7
libcom_err-devel.x86_64 0:1.42.9-19.el7 libkadm5.x86_64 0:1.15.1-50.el7
libmpc.x86_64 0:1.0.1-3.el7 libselinux-devel.x86_64 0:2.5-15.el7
libsepol-devel.x86_64 0:2.5-10.el7 libstdc++-devel.x86_64 0:4.8.5-44.el7
libverto-devel.x86_64 0:0.2.5-4.el7 mpfr.x86_64 0:3.1.1-4.el7
pcre-devel.x86_64 0:8.32-17.el7 perl-Error.noarch 1:0.17020-2.el7
perl-Git.noarch 0:1.8.3.1-23.el7_8 perl-TermReadKey.x86_64 0:2.30-20.el7
Updated:
cpio.x86_64 0:2.11-28.el7 curl.x86_64 0:7.29.0-59.el7_9.1
perl.x86_64 4:5.16.3-297.el7
Dependency Updated:
e2fsprogs.x86_64 0:1.42.9-19.el7 e2fsprogs-libs.x86_64 0:1.42.9-19.el7 expat.x86_64 0:2.1.0-12.el7
glibc.x86_64 0:2.17-317.el7 glibc-common.x86_64 0:2.17-317.el7 krb5-libs.x86_64 0:1.15.1-50.el7
libcom_err.x86_64 0:1.42.9-19.el7 libcurl.x86_64 0:7.29.0-59.el7_9.1
libgcc.x86_64 0:4.8.5-44.el7 libgomp.x86_64 0:4.8.5-44.el7 libss.x86_64 0:1.42.9-19.el7
libstdc++.x86_64 0:4.8.5-44.el7 perl-libs.x86_64 4:5.16.3-297.el7
Complete!
//2、下载Git-2.5.0版本并解压tar包生成makefire:
[root@localhost ~]# wget https://www.kernel.org/pub/software/scm/git/git-2.5.0.tar.gz
[root@localhost ~]# tar -zxvf git-2.5.0.tar.gz
[root@localhost git-2.5.0]# autoconf
[root@localhost git-2.5.0]# ./configure prefix=/usr/local/git/ //生成makefile
//3、make && make install
[root@localhost git-2.5.0]# make
GEN bin-wrappers/test-wildmatch
GEN git-remote-testgit
[root@localhost git-2.5.0]# make install
hatchanged; do \
rm -f "$execdir/$p" && \
test -z "" && \
ln "$execdir/git" "$execdir/$p" 2>/dev/null || \
ln -s "git" "$execdir/$p" 2>/dev/null || \
cp "$execdir/git" "$execdir/$p" || exit; \
done && \
remote_curl_aliases="git-remote-https git-remote-ftp git-remote-ftps" && \
for p in $remote_curl_aliases; do \
rm -f "$execdir/$p" && \
test -z "" && \
ln "$execdir/git-remote-http" "$execdir/$p" 2>/dev/null || \
ln -s "git-remote-http" "$execdir/$p" 2>/dev/null || \
cp "$execdir/git-remote-http" "$execdir/$p" || exit; \
done && \
./check_bindir "z$bindir" "z$execdir" "$bindir/git-add"
//4、配置生效文件及软连接:
[root@localhost git-2.5.0]# vim /etc/profile //将git指令添加到bash中
export PATH=$PATH:/usr/local/git/bin //在profile中添加该内容
[root@localhost git-2.5.0]# source /etc/profile //使配置文件生效
[root@localhost ~]# ln -s /usr/local/git/bin/git /usr/bin/ //创建软连接
[root@localhost git-2.5.0]# git -version
git version 2.5.0
//5、添加用户
[root@localhost ~]# adduser -r -c 'git version control' -d /home/git -m git
//此命令执行后会创建/home/git目录作为git用户的主目录。
[root@localhost ~]# passwd git //为git用户创建密码
[root@localhost ~]# su git //切换到git用户之下
//6、创建repo1仓库
[git@localhost ~]$ git --bare init /home/git/repo1
Initialized empty Git repository in /home/git/repo1/ //创建git仓库repo1.并初始化仓库。推荐使用git --bare init
//如果不使用“--bare”参数,初始化仓库后,提交master分支时报错。
//这是由于git默认拒绝了push操作,需要.git/config添加如下代码:
[receive]
denyCurrentBranch = ignore
[git@localhost ~]$ ls
repo1 //查看服务器上的远程仓库创建完成。
//在本地电脑:右键——>Git Bash Here
$ git remote add origin ssh://git@192.168.1.60/home/git/repo1
//使用命令与远程服务器建立连接
// 私有git服务器搭建完成后就可以向连接github一样连接使用了,
//但是我们的git服务器并没有配置密钥登录,所以每次连接时需要输入密码。
//这种形式和刚才使用的形式好像不一样,前面有ssh://前缀,也可以这样执行
$ git remote add origin git@192.168.1.60:repo1
- 在.git的工作目录之下——>右键——>git同步——>远端URL:管理——>远端:private-git——>URL: ssh://git@192.168.1.60/home/git/repo1——>保存——>推送:服务器用户名:密码——>推送完成——>在Git服务器远程仓库就可查看到仓库文件——>END
[git@localhost ~]$ ls repo1/
branches config description HEAD hooks info objects refs
- 右键——>Git 克隆——>URL: ssh://git@192.168.1.60/home/git/repo1——>目录:E:\NO.2——GitHub Repository\Repository\clone-repos\repo1——>用户名:密码——>克隆完成——END
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
<wiz_marker id="wiz-painter-root" style="">
NO.A.0004——Git私有服务器部署/makefile方式/本地与Git服务器代码交换的更多相关文章
- git远程删除分支后,本地执行git branch -a依然能看到删除分支到底该咋整?
使用命令git branch -a可以查看所有本地分支和远程分支(git branch -r 可以只查看远程分支) 如果发现很多在远程仓库已经删除的分支在本地依然可以看到到底该怎么办呢?(反正强迫症受 ...
- win端git连接私服仓库+上传本地项目+从服务器下载文件到win
win端git连接私服仓库: 1.win端 检查c:/Users/用户/.ssh/目录下是否有config文件(!!!没有任何后缀名).如果没有则新建config文件,然后修改添加如下内容: Host ...
- ubuntu使用ssh远程登录服务器及上传本地文件到服务器
1. ubuntu 远程登录 首先你的ubuntu要能够支持ssh,如果不能,自行百度! 打开终端,输入 ssh root@115.159.200.13(你的服务器的IP地址) 回车就会让你输入 ...
- Nginx + Tomcat 反向代理 如何在高效的在一台服务器部署多个站点
上一篇分享了 Nginx + Tomcat 反向代理 负载均衡 集群 部署指南,感觉还是相当实用型的,但是一般集群部署是基于大访问量的,可能有的企业用不到,类似一些企业官网,访问量并不是很大,基于这个 ...
- Git 系列(一):什么是 Git
欢迎阅读本系列关于如何使用 Git 版本控制系统的教程!通过本文的介绍,你将会了解到 Git 的用途及谁该使用 Git. 如果你刚步入开源的世界,你很有可能会遇到一些在 Git 上托管代码或者发布使用 ...
- git 查看、创建、删除 本地,远程 分支
1. 查看远程分支 git branch -rorigin/master 2. 查看本地分支 git branch *master 注:以*开头指明现在所在的本地分支 3. 查看本地分支和远程分支 g ...
- 一步搞定私有Git服务器部署(Gogs)
http://www.jianshu.com/p/424627516ef6 零.安装 Docker 和 Compsoe 首先安装 Docker: $ curl -sSL https://get.doc ...
- 使用git代替FTP部署代码到服务器的例子
这篇文章主要介绍了使用git代替FTP部署代码到服务器的例子,这种方法可以节省流量.节省时间,需要的朋友可以参考下 本地开发完成后,通常会在服务器上部署,有人会使用ftp,有人会使用scp, ftp和 ...
- 如何使用git和ssh部署本地代码到服务器
一.首先设置好自己本地的Git用户名和密码: git config --global user.name "your name" git config --global user. ...
随机推荐
- PowerShell 定时输出citrix desktop昨日连接会话
asnp citrix*$now_date = [datetime]::Today$day2 = [datetime]::Today - [TimeSpan]::FromHours(24)$fiel_ ...
- 用Hugo在gitee上构建博客(Windows环境下)
目录 用Hugo在gitee上构建博客(Windows环境下) 1.为什么要用gitee? 2.安装git 3.安装Hugo 4.创建远程仓库 5.搭建博客 (以下所有命令都在git bash中输入) ...
- hdu6115 Factory (LCA + 倍增)
Factory Time Limit: 20000/10000 MS (Java/Others) Memory Limit: 132768/132768 K (Java/Others)Total ...
- 【原创】linux实时操作系统xenomai x86平台基准测试(benchmark)
一.前言 benchmark 即基准测试.通常操作系统主要服务于应用程序,其运行也是需要一定cpu资源的,一般来说操作系统提供服务一定要快,否则会影响应用程序的运行效率,尤其是实时操作系统.所以本文针 ...
- ATOM基础教程一使用前端插件emmet(16)
emmet简介 http://blog.csdn.net/zsl10/article/details/51956791 emmet的前身是Zen coding,从事Web前端开发的工程师对该插件并不陌 ...
- 走在深夜的小码农 Fourth Day
Css3 Fourth Day writer:late at night codepeasant 学习大纲 一.emmet语法 1.简介 Emmet语法的前身是Zen coding,它使用缩写,来 ...
- Java学习的第三十天
1.遇到打印文件使用打印流PrintStream 使用PrintStream写入数据 2.没有问题 3.明天学习用RandomAccessFile随机访问文件
- Nginx跳转配置
1.携带目录调转到后端,后端无目录,location配置如下 例子: i2.jusdacfj.com/ideas_edi/--10.0.2.137:7040/10.0.2.138:7040 locat ...
- Learn day8 re正则表达式\search函数\反射\tcp发送消息(循环)\udp发送消息
1.匹配单个字符 # ### 正则表达式 - 单个字符匹配 import re ''' findall 把匹配的结果直接返回到列表中 lst = re.findall("正则表达式" ...
- win10安装linux子系统(wsl)
win10安装linux子系统(wsl) 1.打开Microsoft Store 方式一:在电脑左下角打开 方式二:在电脑左下角的搜索里里输入Microsoft Store 打开Microsoft S ...