• 如何将本地的库推送到github上新建库


    git init 
    git remote add origin https://gitee.com/wjuneking/oos_auth.git 
    git pull --rebase origin master 
    git add . 
    git commit -m"xxx" git push -u origin master 
    git push -u origin master
    

    初始化
    绑定远程仓库
    将远程合并到本地(readme会有不同)
    添加文件
    传到commit
    推送远程仓库

    1.报错以及解决方案

    • 解决error: failed to push some refs to 'xxxx'
    error: failed to push some refs to 'https://github.com/ZJyoung1997/JZShop.git' 
    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. 
    

    原因是远程仓库中的文件和我们本地的仓库有差异,例如你的远程仓库有个文件Readme. md,但是本地仓库却没有,就可能会出现这种情况。
    我的就是远程仓库中有Readme. md文件,而本地仓库中没有该文件造成的。还有就是因为平时在协会中,用协会电脑开发,回到寝室后又会用自己的电脑开发,这可能也是导致这种问题的原因。这种情况有解决办法,就是将本地仓库直接干掉,然后重新从远程clone一个,但是这样显然太麻烦了,可以用合并分支的方法
    解决办法
    git pull --rebase origin master

    git pull命令用于从另一个存储库或本地分支获取并集成(整合),取回远程主机某个分支的更新,再与本地的指定分支合并。

    如果报如下错误,也可以用 git pull 命令

    fatal: 'master' does not appear to be a git repository
    fatal: Could not read from remote repository.
    Please make sure you have the correct access rights
    and the repository exists.
    

    用 git pull origin master --allow-unrelated-histories 解决

    • error: src refspec master does not match any
    error: failed to push some refs to 'https://gitee.com/wjuneking/oos_auth.git'
    

    没有添加要上传的内容,add .就好

    2.指定不上传的文件 创建.gitignore

    /target/ // 忽略这个target 目录
    log/* // 忽略log下的所有文件
    css/*.css // 忽略css目录下的.css文件

  • 相关阅读:
    第六课 使用oflash软件烧写bin文件至开发板
    Linux查看、添加、修改PATH环境变量
    第七课 Linux裸机开发+SourceInsight3.5使用+notepad++使用
    第五课 Linux高级命令
    数组的方法总结
    浅谈 return false 和preventDefault stopPropagation stopImmediatePropagation 的正确用法
    实时统计输入的文字
    滚轮滚动事件
    window.onload和DOMReady
    JS获取浏览器可视区域的尺寸
  • 原文地址:https://www.cnblogs.com/wjune-0405/p/15546595.html
Copyright © 2020-2023  润新知