github私有仓库搭建
git 下载链接 https://registry.npmmirror.com/binary.html?path=git-for-windows/
安装git
1,使用yum安装git
yum -y install git
2,设置git账户
git config --global user.name "xiaoli"
3,设置git邮箱
git config --global user.email "xiaoli@jbct.com"
git config --global color.ui true
4,查看git全局配置
git config --list
5,查看git生成的配置文件
cat .gitconfig
搭建私有仓库
1,生成ssh密钥
ssh-keygen -t rsa
2,查看私钥
cat .ssh/id_rsa.pub
3,GitHub添加ssh密钥步骤
搭建仓库步骤
1,创建git仓库根目录
mkdir Git
2,初始化git仓库
cd /d/Git
git init
3,创建测试文件
touch 1.txt
查看git状态
git status
4,把测试文件从工作目录提交到暂存区域
git add 1.txt
查看git状态
git status
6,关联公网远程仓库
git remote add origin 加你的仓库访问连接
如果报以下错误
fatal: remote origin already exists. (致命:远程来源已经存在)
git remote -v 添加之前可以先查看远程库信息:
可以看到,本地库已经关联了origin的远程库,并且,该远程库指向GitHub。
解决办法如下:
a、先输入$ git remote rm origin(删除关联的origin的远程库)
b、再输入$ git remote add origin git@github.com:(github名)/(git项目名).git 就不会报错了!
c、如果输入$ git remote rm origin 还是报错的话,error: Could not remove config section 'remote.origin'. 我们需要修改gitconfig文件的内容
d、找到你的github的安装路径,我的是C:\Users\ASUS\AppData\Local\GitHub\PortableGit_ca477551eeb4aea0e4ae9fcd3358bd96720bb5c8\etc
e、找到一个名为gitconfig的文件,打开它把里面的[remote "origin"]那一行删掉就好了!
7,把测试文件从本地仓库上传到公网仓库
git push -u origin master
8,登录GitHub查看上传的文件
9,git客户端文件下载
git clone 仓库链接
10,清除git缓存
git rm -r --cached .
GitHub使用
创建仓库
删除仓库
添加ssh密钥
添加后保存
原文链接:
github私有仓库搭建_天道酬勤·的博客-优快云博客_github私有仓库
fatal: remote origin already exists. (远程来源已经存在 解决办法)_码知秋的博客-优快云博客