git提交

作者: 寻Sweet | 来源:发表于2019-05-07 22:42 被阅读0次

Your branch and 'origin/master' have diverged, and have 1 and 1 different commits each, respectively

当我们在本地提交到远程仓库的时候,如果遇到上述问题,我们可以首先使用如下命令:
git rebase origin/master
然后使用
git pull --rebase
最后使用
git push origin master
把内容提交到远程仓库上。
直接复制如下运行即可
1.git rebase origin/master
2.git pull --rebase
3.git push origin master

Updates were rejected because the remote contains work that you do

每次建立新的仓库,提交的时总会出现这样的错误,真是头疼,......
直接开始正题,git 提交的步骤:

  1. git init //初始化仓库
  2. git add .(文件name) //添加文件到本地仓库
  3. git commit -m "first commit" //添加文件描述信息
  4. git remote add origin + 远程仓库地址 //链接远程仓库,创建主分支
  5. git push -u origin master //把本地仓库的文件推送到远程仓库
    提交之后就会出现以下错误


    image.png

    要想解决以上错误,只需要在4,5之间使用git pull origin master即可

正确步骤:

  1. git init //初始化仓库

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

  3. git commit -m "first commit" //添加文件描述信息

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

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

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

OK
搞定,回家吃饭!!
看的故事多了,才慢慢知道,话说多了就是打自己的脸!

相关文章

  • GIT命令

    新建路径: git clone 提交修改: git add . 本地提交: git comm...

  • 关于Git

    首次提交5条 git init .......git 重复提交3条 git add . git commit -m...

  • git常用命令

    git add . git commit -m "message"提交,其中message是提交的信息。 git ...

  • git 常用的命令

    git status 检测状态 git add . 提交的代码显示 git commit -m "备注" 提交...

  • 05_git版本回退和版本比较

    git log git的历史提交记录 commit 后面的hash值是 git提交id git log --pre...

  • 《git权威指南笔记》

    修改提交说明 git commit --amend修改最新提交的提交说明 git rebase -i

  • git撤销与回滚

    git撤销已经push的提交 git log 查看提交记录 git reset --soft commit_id ...

  • git常用命令总结

    目录 拆pr git log 查看历史提交 git reset 回滚到提交前,但是这时候未提交文件还在 git a...

  • Git 提交代码到远程分支

    环境:windows 提交方式:Git Bash 命令行提交 1.进入需要提交的项目Git目录右键选择Git Ba...

  • git 代码合并

    git 代码合并 git status 查看下当前代码状态,有需要提交的就提交,没用需要提交的就保持原样 git ...

网友评论

    本文标题:git提交

    本文链接:https://www.haomeiwen.com/subject/zkvuoqtx.html