git 远程仓库创建 及 本地仓库操作

linux高版本安装

https://blog.csdn.net/weixin_42765596/article/details/102716395?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.add_param_isCf&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-2.add_param_isCf

按照这个链接的内容操作,之后加一些修改

https://www.cnblogs.com/dee0912/p/5815267.html

初始化仓库
git init
添加本地修改
git add
提交本地修改
git commit -m ‘XXX’
链接到远程仓库
git remote add origin git@远程地址(ip/域名):远程仓库的根目录(/xx/xx/xx.git)
本地分支提交到远程分支
git push -u origin 分支名
从远程分支拉取到本地
git clone git@远程地址(ip/域名):远程仓库的根目录(/xx/xx/xx.git)
从远程获取最新版本到本地,不会自动merge
git fetch origin master
将分支master与当前分支进行合并
git merge origin/master

注意的是在远程创建仓库之后需要将操作权限修改为 对应的用户权限
即链接的用户

重启 sshd 服务命令:
systemctl restart sshd
会出现的错误:

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 139.155.181.46:/data/git/yd.git
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to ‘139.155.181.46:/data/git/yd.git’

这是由于git默认拒绝了push操作,需要进行设置,修改本地和远程仓库的 .git/config 文件后面添加如下代码:
[receive]
denyCurrentBranch = ignore

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值