git本地推送到远程仓库

在本地的learngit仓库下运行命令:

$ git remote add origin git@github.com:michaelliao/learngit.git 关联远程仓库

$ git remote add origin https://github.com/JackLiu16/ansible

$ git remote add origin https://github.com/JackLiu16/ansible第二次执行这个命令会出现错误
fatal: remote origin already exists. 



$ git remote remove origin https://github.com/JackLiu16/ansible
usage: git remote remove <name>

$ git remote remove origin 只需要origin这个名字就可以了,不用后面的网址。origin这个名字是和该网址库相关联的别名,
可以自己任意定义


请千万注意,把上面的michaelliao替换成你自己的GitHub账户名,否则,你在本地关联的就是我的远程库,关联没有问题,但是你以后推送是推不上去的,因为你的SSH Key公钥不在我的账户列表中。

添加后,远程库的名字就是origin,这是Git默认的叫法,也可以改成别的,但是origin这个名字一看就知道是远程库。也可以关联多个远程仓库。名字也可以任意自定义。

下一步,就可以把本地库的所有内容推送到远程库上:

$ git push -u origin master
$ git push -u origin master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 289 bytes | 289.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/JackLiu16/ansible
   831c8e3..4e8ef8a  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

报错:

$ git push origin
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

$  git push --set-upstream origin master
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/JackLiu16/ansible'

$ git push -u origin master
error: src refspec master does not match any.
error: failed to push some refs to 'https://github.com/JackLiu16/ansible'

原因:

本地仓库为空

解决方法:使用如下命令 添加文件;

$ git add add.php addok.php conn.php del.php edit.php editok.php ftpsql.sql index.php

$ git commit -m "init files"


参考:https://www.cnblogs.com/jeremylee/p/5715289.html

https://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/0013752340242354807e192f02a44359908df8a5643103a000

https://blog.csdn.net/dengjianqiang2011/article/details/9260435

https://www.jianshu.com/p/dcbb8baa6e36
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值