可能的重复问题:
git push错误“[remote rejected] master -> master (branch is currently checked out)”
我是Git的新手,正在尝试将其用于本地grails项目。
我遵循的步骤:
- 创建grails项目
- 进入项目目录并执行
git init
- 将项目中的所有文件添加到暂存区并提交
仓库中的git状态会显示以下消息:
BXX@BXX-PC /c/Work/Grails/projects/yyy/tables (master) $ git status # On branch master nothing to commit (working directory clean)
尝试将其保持为主分支,通过克隆仓库进行更改,稍后将更改推回。为此:
在我的IDE中,检出项目(IntelliJ)。实际上,这将把项目克隆到另一个目录中。
进行更改并提交项目。
将本地更改推送到主分支。
15:41:56.249: git push -v origin master
Pushing to c:/Work/Grails/projects/xxx/tables
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.
克隆的仓库状态为:
$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
#
nothing to commit (working directory clean)
请帮助我理解这个问题。有没有更好的工作流程可以遵循?我可能能够通过Intellij初始化存储库,然后尝试在主分支上工作。仍然不确定上面的问题是什么。谢谢。
git push origin master:foo
。 - kenorb