首页 > 解决方案 > 如何解决 git push 被拒绝的错误?

问题描述

╭─ksoo@ksoo-compnay ~/hisdk/mpp  ‹devel*› 
╰─$ git push origin devel                                                                                                                                                 1 ↵
Everything up-to-date
╭─ksoo@ksoo-compnay ~/hisdk/mpp  ‹devel*› 
╰─$ git status 
On branch devel
Your branch is up-to-date with 'origin/devel'.
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    include/cscope
    include/cscope.files
    sample/cscope.out

nothing added to commit but untracked files present (use "git add" to track)
╭─ksoo@ksoo-compnay ~/hisdk/mpp  ‹devel*› 
╰─$ git checkout devel 
Already on 'devel'
Your branch is up-to-date with 'origin/devel'.
╭─ksoo@ksoo-compnay ~/hisdk/mpp  ‹devel*› 
╰─$ git push
To git@github.com:varram-suh/mpp.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:xxxx/xxxx.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and 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.
╭─ksoo@ksoo-compnay ~/hisdk/mpp  ‹devel*› 
╰─$ git pull                                                                                                                                                              1 ↵
Current branch devel is up to date.
╭─ksoo@ksoo-compnay ~/hisdk/mpp  ‹devel*› 
╰─$ git push
To git@github.com:varram-suh/mpp.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'git@github.com:xxxx/xxx.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and 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.

git push 时出现错误,可能是分支问题。如果我指定一个分支,我不会收到错误消息。

例如,当我运行命令时 git pull origin develgit push origin devel

之前没有错误。我将如何解决这个问题?

编辑:我使用 'git config --global push.default current' 解决了这个问题

之前没有报错,为什么我的 git config 变了?

标签: git

解决方案


推荐阅读