侧边栏壁纸
博主头像
liveJQ博主等级

沒有乐趣,何来开始

  • 累计撰写 171 篇文章
  • 累计创建 67 个标签
  • 累计收到 2 条评论

Git建立仓库后推送失败

liveJQ
2020-05-08 / 0 评论 / 0 点赞 / 841 阅读 / 1,716 字

问题描述

$ git pull https://github.com/livejq/xxx.git master
fatal: HttpRequestException encountered.
From https://github.com/livejq/Chatroom
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

原因

在建立远程仓库后一并生成了README.md文件,导致与本地产生了不同的版本(历史)差异

解决办法

方法一:强制推送

如果你百分百确定远程仓库中的资料没啥用,那么可以直接使用此方式将自己本地的版本完全替代远程仓库中的版本。

usage: git push [<options>] [<repository> [<refspec>...]]

    -v, --verbose         be more verbose
    -q, --quiet           be more quiet
    --repo <repository>   repository
    --all                 push all refs
    --mirror              mirror all refs
    -d, --delete          delete refs
    --tags                push tags (can't be used with --all or --mirror)
    -n, --dry-run         dry run
    --porcelain           machine-readable output
    -f, --force           force updates
    --force-with-lease[=<refname>:<expect>]
                          require old value of ref to be at this value
    --recurse-submodules[=(check|on-demand|no)]
                          control recursive pushing of submodules
    --thin                use thin pack
    --receive-pack <receive-pack>
                          receive pack program
    --exec <receive-pack>
                          receive pack program
    -u, --set-upstream    set upstream for git pull/status
    --progress            force progress reporting
    --prune               prune locally removed refs
    --no-verify           bypass pre-push hook
    --follow-tags         push missing but relevant tags
    --signed[=(yes|no|if-asked)]
                          GPG sign the push
    --atomic              request atomic transaction on remote side
    -o, --push-option <server-specific>
                          option to transmit
    -4, --ipv4            use IPv4 addresses only
    -6, --ipv6            use IPv6 addresses only
    
    $ git push origin master -f
Enumerating objects: 3357, done.
Counting objects: 100% (3357/3357), done.
Delta compression using up to 4 threads
Compressing objects: 100% (3337/3337), done.
Writing objects: 100% (3357/3357), 9.51 MiB | 902.00 KiB/s, done.
Total 3357 (delta 8), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (8/8), done.
To https://github.com/livejq/Chatroom.git
 + baf5041...87212e7 master -> master (forced update)

方法二:手动合并

clone到本地,然后将自己的代码添加进去,按常规流程操作后再push

0

评论区