• git常见错误


    不常git不是一个好习惯。一旦git就会发现一堆错误,当着急分享代码给小伙伴的时候,这就情况不妙了,所以贴一些我遇到的错误。

    当利用git bash向已存在的库中上传新代码时

    执行 git push origin master报错:
    To http://git.XXX.com/XXX/xxx
     ! [rejected]        master -> master (fetch first)
    error: failed to push some refs to 'http://git.XXX.com/XXX/xxx'
    hint: Updates were rejected because the remote contains work that you do
    hint: not have locally. This is usually caused by another repository pushing
    hint: to the same ref. You may want to first integrate the remote changes
    hint: (e.g., 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.

    提示得很清楚,远程代码库和本地代码库不一致,应该先把远程代码库本地化,即先执行git pull 。

    所以接下来我们执行 git pull --rebase origin master

    又报错:

    error: cannot pull with rebase: You have unstaged changes.
    error: please commit or stash them.

    可以看出:如果有未提交的更改,不能git pull

    只需

    $ git stash
    Saved working directory and index state WIP on master: 007c150 first commit

    这时我们就可以拉取远程代码库的代码到本地了

    $ git pull --rebase origin master

    拉取完成

    再执行git stash pop


    git stash #可用来暂存当前正在进行的工作
    git stash pop #从Git栈中读取最近一次保存的内容

    ————————————————————————————————————————————————————————————————————

    现在可以上传本地代码了!!!

    执行git push origin master?

    no no no !!! 这样会报错:

    $ git push origin master
    Everything up-to-date

    这是因为没有在本地commit呀

    那么

    git add .

    git commit -m 'update'

    可以通过命令git status来查看是否还有文件未提交

    最后git push origin master就可以了。

  • 相关阅读:
    GoF23种设计模式之己见
    全面阐述某系统设计所实现的质量属性战术
    对XX系统的可用性和易用性改良
    《淘宝网》的质量属性描述
    读《架构漫谈》之后
    软件架构之再理解
    《架构之美》阅读笔记06
    《架构之美》阅读笔记05
    《架构之美》阅读笔记04
    《架构之美》阅读笔记03
  • 原文地址:https://www.cnblogs.com/AbsolutelyPerfect/p/8320286.html
Copyright © 2020-2023  润新知