最近由于经常迁移项目到另一台机器上进行部署更新一点就要整个迁移 弄得麻烦了
就在网上学了一下这个方式
首先我们在想要建立裸仓库的电脑上找到一个文件夹放置我们的裸仓库
在此点击鼠标右键选择 open git bash here
输入命令 创裸仓库
git init --bare gitTestName.git
这样裸仓库就已经构建了
现在来到一个我们存放项目的地方 也就是本地的仓库的位置
在此鼠标右键 打开git命令行
输入 创建本地仓库(没有的话)
git init
添加远程仓库(也就是刚刚的裸仓库)这是目前我本机上的本地路径
git remote add originName /Y/YSP/UE_project/gitTest/gitTestName.git
originName 是你想对远端仓库取的名字
输入 检查一下
git remote -v
这样的远端仓库就添加成功了
在本地仓库随便创建一个文件
添加到暂存
git add .
提交到本地仓库
git commit -m"t"
推送到远程仓库
git push originName master
master 是分支名称 这个远程仓库没有分支 会进行创建 有则不会
我们来到远程仓库 看到已经有提交了
现在我们要去另一台电脑上了
对了我这个是Windows系统的 首先要保证 我们的裸仓库文件夹是可以被网络发现的
另一台电脑上 先创建一个文件夹
打开网络映射器
选择我们在网络发现里的裸仓库文件夹 点击确定(上一级)
输入
git clone /X/gitTestName.git
path 是 刚刚映射出来的裸仓库文件夹 等待片刻即可
如果报错
Cloning into 'gitTestName'...
fatal: detected dubious ownership in repository at 'X:/gitTestName.git'
'X:/gitTestName.git' is owned by:
(inconvertible) (S-1-5-21-1197519011-1549774375-2643100596-1001)
but the current user is:
DESKTOP-DQ6V1QT/dell (S-1-5-21-1450924175-3348304483-3808369906-1001)
To add an exception for this directory, call:
git config --global --add safe.directory X:/gitTestName.git
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
添加这句
git config --global --add safe.directory X:/gitTestName.git
再去
git clone /X/gitTestName.git
这样就成功了
随便写点东西
先提交到本地仓库 再 上传到远程仓库
现在我们来到第一台电脑进行查看 裸仓库(远程仓库)
看到已经有提交了
我们现在 拉取下来看看
git pull originName master
好了 这边成功可以拉取到
局域网测试成功 当然还有其他的方式 目前我不会