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就可以了。

  • 相关阅读:
    VMware VSAN 设计规则
    通过命令行给 XenServer 打补丁
    XenServer 根分区空间满的解决办法
    sftp命令不被识别
    windows cmd窗口提示“telnet”命令不能内部或外部命令,也不是可运行的程序
    Eclipse安装ModelGoon控件(ModelGoon控件反向生成UML)
    WINDOWS8.1安装ORACLE客户端及配置
    CentOs下安装maven
    centos下安装java8
    mono支持gb2312
  • 原文地址:https://www.cnblogs.com/AbsolutelyPerfect/p/8320286.html
Copyright © 2011-2022 走看看