zoukankan      html  css  js  c++  java
  • 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就可以了。

  • 相关阅读:
    RMAN 高级恢复
    从问题域出发认识Hadoop生态系统
    下一代 Hadoop YARN :相比于MRv1,YARN的优势
    Sensei:分布式, 实时, 半结构化数据库
    盘点2012:云计算的春天
    Apache Tajo:一个运行在YARN上支持SQL的分布式数据仓库
    实现多个jetty实例开机后自动启动
    淘宝在数据处理领域的项目及开源产品介绍
    SenseiDB架构设计分析
    在Hadoop上运行SQL:程序员需知晓的13种数据工具
  • 原文地址:https://www.cnblogs.com/AbsolutelyPerfect/p/8320286.html
Copyright © 2011-2022 走看看