gpt4 book ai didi

Git 推送不起作用

转载 作者:行者123 更新时间:2023-12-05 07:48:00 27 4
gpt4 key购买 nike

嗨,我是 Git 的新手,我尝试创建一个本地存储库并提交代码,但是当我尝试在我的推送命令上推送代码时,出现此错误

    SUMITs-Mac-mini:gitupload sumit$ git push -u origin master
To https://github.com/sumittiwari87/First-Gulp-Lesson.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/sumittiwari87/First-Gulp-Lesson.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.

所以我尝试 pull 提交更改,然后又收到错误。

 SUMITs-Mac-mini:gitupload sumit$ git pull origin master
warning: no common commits
remote: Counting objects: 4, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), done.
From https://github.com/sumittiwari87/First-Gulp-Lesson
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
Auto packing the repository in background for optimum performance.
See "git help gc" for manual housekeeping.
fatal: refusing to merge unrelated histories

我不明白为什么会这样。

最佳答案

fatal: refusing to merge unrelated histories

您的分支没有一个共同的历史提交基础。默认情况下允许此行为,但通常不是预期的结果(不同的提交)。

您可以在 merge 时使用 --allow-unrelated-histories(默认情况下 pull 只是获取 + merge ,可以配置为执行 rebase )。但通常这不是故意的,尤其是你是 git 的新手(除非你知道这种行为和历史)。

我的建议是查看此存储库的本地和远程历史记录:git log --oneline --decorate --all --graph。如果您在解释输出方面需要帮助,请随时编辑您的问题以显示此输出。

关于Git 推送不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39067817/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com