git - SmartGIt "Not all refs have been pushed"错误

标签 git smartgit

作为一个完全的菜鸟,我根本无法使用 SmartGit。 Git 术语太困惑了。

这是我做的, 我创建了两个存储库,Repo1 和 Repo2 在 SmartGit 中

  1. 将 Repo1 初始化为 GIT
  2. 将 Repo1 克隆到 Repo2
  3. 在 Repo1 中添加了一个文本文件并向其中添加了一些文本。
  4. 为 Repo2 pull
  5. 对文本文件做了一些改动
  6. promise
  7. 现在,当我尝试将这些更改推送到 Repo1 时,我得到了 “并非所有引用都已被推送”错误“

更新:

Push: Not all refs have been pushed.
    'master' rejected (non-fast-forward)
    Counting objects: 10, done.
    Delta compression using up to 2 threads.
    Compressing objects:  20% (1/5)   
    Compressing objects:  40% (2/5)   
    Compressing objects:  60% (3/5)   
    Compressing objects:  80% (4/5)   
    Compressing objects: 100% (5/5)   
    Compressing objects: 100% (5/5), done.
    Writing objects:  12% (1/8)   
    Writing objects:  25% (2/8)   
    Writing objects:  37% (3/8)   
    Writing objects:  50% (4/8)   
    Writing objects:  62% (5/8)   
    Writing objects:  75% (6/8)   
    Writing objects:  87% (7/8)   
    Writing objects: 100% (8/8)   
    Writing objects: 100% (8/8), 726 bytes, done.
    Total 8 (delta 0), reused 0 (delta 0)
    remote: error: refusing to update checked out branch: refs/heads/master
    remote: error: By default, updating the current branch in a non-bare repository
    remote: error: is denied, because it will make the index and work tree inconsistent
    remote: error: with what you pushed, and will require 'git reset --hard' to match
    remote: error: the work tree to HEAD.
    remote: error: 
    remote: error: You can set 'receive.denyCurrentBranch' configuration variable to
    remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into
    remote: error: its current branch; however, this is not recommended unless you
    remote: error: arranged to update its work tree to match what you pushed in some
    remote: error: other way.
    remote: error: 
    remote: error: To squelch this message and still keep the default behaviour, set
    remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
    error: failed to push some refs to '/home/sdr1/Desktop/LocalRepository'

最佳答案

请阅读错误信息部分:

remote: error: By default, updating the current branch in a non-bare repository
remote: error: is denied, because it will make the index and work tree inconsistent
remote: error: with what you pushed, and will require 'git reset --hard' to match
remote: error: the work tree to HEAD.

Git 阻止推送到非裸存储库(此处为 Repo1)的分支,因为这会使工作树、索引和 HEAD 不一致或非常容易出错。

解决方案: 将您的原始存储库 (Repo1) 切换到不同的分支,然后再次尝试从克隆 (Repo2) 推送。

关于git - SmartGIt "Not all refs have been pushed"错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16394209/

相关文章:

Git:git verify-pack返回的object 'size'的含义

git - 如何导入旧设置/存储库

git - 如何在git日志中查看快进 merge ?

git - VSCODE : I want to do "git merge --squash" from vscode

git - 如何在 GitHub 中使用 REST API 列出给定主题的所有存储库?

git - 如何在 cherry-pick smartgit 上保留原作者

git - Smartgit始终 pop 登录表单

git - 如何在 smartgit 中添加孤立分支

git - Azure devops 存储库和 TFVC 之间有什么关系?在 GIT 和 TFVC 之间进行选择的选项在哪里?

git - 将 Google Colab ipynb 推送到 Github?