自己搭建Git服务器实现SSH以及远程仓库迁移
来源:互联网 发布:程序员大牛 编辑:程序博客网 时间:2024/06/05 20:36
创建git远程仓库:
请参考大神的搭建Git远程创库
迁移远程仓库:
在工作过程由于原来的线上服务器不能用了,需要将上面git管理的原代代码迁移的新的服务器。
我想到了两种方法:
1. 直接从远程仓库clone :
git clone --bare user@url git clone --bare git@127.0.0.1:/srv/code/ams.git
2.先创建一个git空仓库, 再将本地代码push到远程仓库中:
//创建远程仓库 git init --bare temp.git //修改本地远程仓库地址 git remote set-url origin git@127.0.0.1:/srv/code/ams.git
在push到新的远程仓库时可能会遇到下面的错误:
remote: error: insufficient permission for adding an object to repository database ./objectsremote: fatal: failed to write objecterror: unpack failed: unpack-objects abnormal exitTo git@xxx.xxx.xxx.xxx:/srv/resource/ams.git! [remote rejected] master -> master (unpacker error)error: failed to push some refs to 'git@xxx.xxx.xxx.xxx:/srv/resource/ams.git'
这是由于在clone或新建远程仓库时用户不是git,用 ls -l 命令查看仓库的拥有者。
如果不是git 可用以下命令修改:
chown -R [用户]:[用户组] [目录] chown -R git:git xxx.git
其中 参数 -R 表示其子目录和文件一同修改。
生成ssh-key
为了安全访问远程仓库一般使用ssh。
1.配置用户名和邮箱:
//user git config --global user.name [username] git config --global user.email [email]
2.生成ssh-key:
git ssh-keygen
window 下生成的key一般在C:\Users\当前用户\ .ssh 这个文件夹下。详细的看这里
3. 在linux服务器上添加公钥:
将id_rsa.pub文件打开将里面的字符串复制到服务其上 /home/git/.ssh/authorized_keys 这个文件里面然后保存退出。
vim /home/git/.ssh/authorized_keys
如果没有这个文件,就用vim新建一个同名文件。添加好后就可以实现ssh访问了
阅读全文
1 0
- 自己搭建Git服务器实现SSH以及远程仓库迁移
- git搭建服务器,远程仓库
- GIT CENTOS 7安装以及服务器远程仓库搭建教程
- Git远程仓库搭建、设置Git服务器
- 远程服务器git仓库的搭建以及本地git库的首次推送首次克隆远程仓库的文件
- Git 远程仓库/ssh
- git仓库相关知识03-搭建远程仓库服务器
- git 远程仓库的迁移
- git 服务器搭建,在自己服务器上搭建私有仓库
- git 服务器搭建,在自己服务器上搭建私有仓库
- git 服务器搭建,在自己服务器上搭建私有仓库
- 搭建Git远程仓库
- git:搭建远程仓库
- 搭建远程Git仓库
- 远程Linux服务器下搭建Git远程仓库
- 搭建GIT服务器仓库
- 在服务器上搭建自己的Git仓库(摘录整合)
- git迁移远程仓库后报错的解决办法
- BZOJ 1801 [Ahoi 2009] DP 解题报告
- Android 解析异步消息处理机制
- HTML笔记
- Spring及三大框架整合
- Effective C++ 18. Make interfaces easy to use correctly and hard to use incorrectly
- 自己搭建Git服务器实现SSH以及远程仓库迁移
- SQL中先分组再组内排序再输出的ROW_NUMBER() OVER(partition by..order by..)
- 针对一些自定义的,中央仓库没有的jar包,需要从将jar放到lib中
- 1.Python---01
- vue computed 与 watch 区别
- JSP中的<%= %>和${ }到底有什么区别?
- CSS Mastery摘要(5)--Content Layout
- 多态,抽象类,接口
- [python3]爬虫实战二之爬取百度贴吧帖子