• 上传github文件及所出现的问题


    上传github所发现的问题

    准备工作

    使用 git bush 输入下面的命令

    git config --global user.email "you@example.com"
    git config --global user.name "Your Name"

    上传代码到 GitHub 的步骤:

    参考 两种方法上传本地文件到 GitHub

    1. 新建一个文件夹 ,放入需要上传的代码文件
    2. 使用 git 进入到该文件夹下
    3. 执行 git init
    4. 执行 git add .
    5. 执行 git commit -m "upload"
    6. 执行 git remote add origin https://github.com/yourname/yourrepository.git
    7. 执行 git push -u origin master

    使用 git push -u origin master 出现的问题

     ! [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to 'git@github.com:zweros/DataStructure.git'
    hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. Integrate the remote changes (e.g.
    hint: 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    

    然后按照网上的文章说 git pull origin master

    使用 git pull origin master 发现的问题

    *branch master -> FETCH_HEAD
    
    fatal: refusing to merge unrelated histories
    

    解决方案

    参考stackoverflow

    You need to either `reset` or `commit` your changes first:
    
        git reset --hard
    
    or:
    
        git commit -m "saving changes..."
    
    Then you can do:
    
        git pull origin master --allow-unrelated-histories

    最后终于能上传成功了

    $ git push -u origin master
    Enumerating objects: 204, done.
    Counting objects: 100% (204/204), done.
    Delta compression using up to 4 threads.
    Compressing objects: 100% (91/91), done.
    Writing objects: 100% (203/203), 2.65 MiB | 21.00 KiB/s, done.
    Total 203 (delta 111), reused 202 (delta 111)
    remote: Resolving deltas: 100% (111/111), done.
    To github.com:xxx/xxx.git
       7838db7..e4721c9  master -> master
    Branch 'master' set up to track remote branch 'master' from 'origin'.
    
  • 相关阅读:
    NTP服务安装
    Teambition 的使用
    搭建svn服务器和测试
    通过NTP协议进行时间同步
    转利用OpenSSL库对Socket传输进行安全加密(RSA+AES)
    转源码编译安装MySQL5.6.12详细过程
    CentOS 6.4安装ffmpeg2.4.2 支持h.265
    转:CentOS 6.4 64-bit编译安装ffmpeg
    Work 2013 博客园挂博客
    FLASH和EEPROM的最大区别
  • 原文地址:https://www.cnblogs.com/zwer/p/10462119.html
Copyright © 2020-2023  润新知