git本地仓库代码push推到github线上基础指令

将文件夹初始化成本地仓库:git init

代码添加:  git add .

查看远程仓库 :git remote -v  

提交:git commit -m "first commit"

git remote add origin git@github com:leiphp/awesome-python3-webapp.git

推送远程仓库:git push [remoteName] [localBranchName]

比如:git push origin_ssh main

报错:hint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first integrate the remote changeshint: (e.g., 'git pull ...') before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解决方法:

 git init //初始化仓库

  1. git add .(文件name) //添加文件到本地仓库

  2. git commit -m “first commit” //添加文件描述信息

  3. git remote add origin + 远程仓库地址 //链接远程仓库,创建主分支

  4. git pull origin master // 把本地仓库的变化连接到远程仓库主分支

  5. git push -u origin master //把本地仓库的文件推送到远程仓库

如果确保本地没问题的话,可以直接用git push -f强行上传

如果还是出错可以把git pull origin master换成git pull --rebase origin master,就把远程仓库的文件同步到本地,本地就多了readme文件了,就可以上传了

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

扶我起来敲代码啊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值