git上传本地内容到远程仓库

首先使用bash here打开git的命令行。然后进入到你的项目当中,首先实例化你的项目。

git init

声明之后,我们可以创建一个将要上传的远程仓库。

git remote add 仓库名 https://gitee.com/

这个地方的网址你必须拥有这个仓库!
然后就可以使用一系列上传

git add .
git commit -m""
git push origin master

进行上传,如果这里报错。

error: failed to push some refs to 'https://gitee.com/tutoucikecmc/gallery'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

是远程仓库的内容跟本地仓库的内容不同步,这时候就需要先爬取远程仓库的内容。使用

git pull <远程仓库名>

如果这个时候提醒你没有额外声明一个分支branch的话。
也就是这个

You asked to pull from the remote 'origin', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.

你可以使用

git branch --set-upstream-to=origin/master  master

意思是声明origin/master 远程仓库和本地仓库合并默认的master本地仓库分支
接下来就可以使用pull了。使用了pull之后,本地和远程仓库同步,在使用push进行上传即可。
如果你接下来pull出现,refusing to merge unrelated,它意思是两个仓库没有本质联系,他这样是不安全的,你可以使用。

git pull <远程仓库名> --allow-unrelated-histories

这样就可以允许不相关的内容合并,内容同步后,再进行push就好了。

所以这里我推荐你可以利用clone命令进行同步,这样就可以不使用这个命令了,这样做是不安全的。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值