我学习Git和起初它似乎确定,但是当我试图把主文件中的变化我得到了这些错误:如何使用Git命令行推送更改?
Counting objects: 3, done.
Writing objects: 100% (3/3), 232 bytes | 0 bytes/s, done.
Total 3 (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'.
To C:\wamp\www\MyGit\myfirstgit
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to 'C:\wamp\www\MyGit\myfirstgit'
确定这里就是我所做的:
我创建我的主文件夹
- C:\ WAMP \ WWW \ MyGit \ myfirstgit
结帐的文件夹到\ WWW
- C:\瓦帕\ WWW \ myfirstgit
我创建的自述文件
- C:\瓦帕\ WWW \ myfirstgit>回声 'TEST自述'>自述
检查状态 C:\瓦帕\ WWW \ myfirstgit> git的状态
在分支主
初始提交
未跟踪文件: (使用“混帐添加...”中包括哪些将被提交)
README
没有加入到承诺,但未跟踪文件存在(使用“混帐添加”追踪)
添加并提交更改
C:\ WAMP \ WWW \ myfirstgit> git的添加自述
C:\ WAMP \ WWW \ myfirstgit> git的承诺-m “我的第一个承诺”
[主站(根提交)43bad4e]我的第一承诺 1文件改变时,1个插入(+) 创建模式100644自述
然后我推变化:
- C: \ WAMP \ WWW \ myfirstgit>混帐推起源主
我也试过指出了目录,但错误:
C:\wamp\www\myfirstgit>git push origin C:\wamp\www\MyGit\myfirstgit
fatal: remote part of refspec is not a valid name in C:\wamp\www\MyGit\myfirstgit
然后我得到了上面的错误。
你能帮我吗?我是使用这个工具的新手。
谢谢。
你git init的第一个文件夹? –
问题在于您正在推送到非裸存储库。错误信息解释了这个问题。一个更加正常的工作流程是,你有一个裸机存储库是“权威”的存储库,而你的其他存储库则是从这个存储库中抽出来的。 –
http://bitflop.com/tutorials/git-bare-vs-non-bare-repositories.html –