git 推送远程仓库
我的闪存驱动器上有一个本地工作副本存储库和一个远程存储库。我之前已经推送到闪存驱动器,但我似乎无法再这样做。
在这里,我进入闪存驱动器上的远程存储库,查看我所在的分支并查看日志。然后我回到我的工作副本本地存储库,编辑一个文件,添加该文件,进行提交并尝试将其推送到我的闪存驱动器,但它不起作用。谁能告诉我我做错了什么吗?
David-Adamss-MacBook-Pro:~ davidadams$ cd /volumes/thumbdrive/repo/releventz
David-Adamss-MacBook-Pro:releventz davidadams$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#
nothing to commit (working directory clean)
David-Adamss-MacBook-Pro:releventz davidadams$ git branch
* master
David-Adamss-MacBook-Pro:releventz davidadams$ git log
commit 65328c9603f62b7a2058f38fb441605b0c4c431e
Author: David Adams <[email protected]>
Date: Wed Jun 29 23:30:40 2011 -0500
third commit
commit b3883fa933609db634b98d747299c1e9c96e8269
Author: David Adams <[email protected]>
Date: Wed Jun 29 23:10:53 2011 -0500
second commit
commit 54832381a6fe898408c9e07bc8409a2982ec6274
Author: David Adams <[email protected]>
Date: Wed Jun 29 22:20:04 2011 -0500
changed checklist.php
commit 1955664689313a589543576477e0a134f26cc313
Author: David Adams <[email protected]>
Date: Wed Jun 29 22:12:53 2011 -0500
first releventz commit
David-Adamss-MacBook-Pro:releventz davidadams$ cd
David-Adamss-MacBook-Pro:~ davidadams$ cd
David-Adamss-MacBook-Pro:~ davidadams$ cd /applications/mamp/htdocs/releventz
David-Adamss-MacBook-Pro:releventz davidadams$ git status
# On branch master
nothing to commit (working directory clean)
David-Adamss-MacBook-Pro:releventz davidadams$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: application/libraries/calendarclass.php
#
no changes added to commit (use "git add" and/or "git commit -a")
David-Adamss-MacBook-Pro:releventz davidadams$ git add .
David-Adamss-MacBook-Pro:releventz davidadams$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: application/libraries/calendarclass.php
#
David-Adamss-MacBook-Pro:releventz davidadams$ git commit -m 'blah blah'
[master 853232d] blah blah
1 files changed, 1 insertions(+), 1 deletions(-)
David-Adamss-MacBook-Pro:releventz davidadams$ git push flashdrive master
Counting objects: 17, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (12/12), 1.89 KiB, done.
Total 12 (delta 8), reused 0 (delta 0)
Unpacking objects: 100% (12/12), done.
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 t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
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 som
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, se
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
gTo /volumes/thumbdrive/repo/releventz
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '/volumes/thumbdrive/repo/releventz'
I have a local working copy repo and a remote repo on my flash drive. I've pushed to the flashdrive before but i can't seem to do it again.
here i went into my remote repo on my flashdrive to see which branch i was on and looked at the log. Then i went back into my working copy local repo, edited a file, added that file, made a commit and attempted to push it my flashdrive but it didn't work. Can any tell what i'm doing wrong?
David-Adamss-MacBook-Pro:~ davidadams$ cd /volumes/thumbdrive/repo/releventz
David-Adamss-MacBook-Pro:releventz davidadams$ git status
# On branch master
# Your branch is ahead of 'origin/master' by 2 commits.
#
nothing to commit (working directory clean)
David-Adamss-MacBook-Pro:releventz davidadams$ git branch
* master
David-Adamss-MacBook-Pro:releventz davidadams$ git log
commit 65328c9603f62b7a2058f38fb441605b0c4c431e
Author: David Adams <[email protected]>
Date: Wed Jun 29 23:30:40 2011 -0500
third commit
commit b3883fa933609db634b98d747299c1e9c96e8269
Author: David Adams <[email protected]>
Date: Wed Jun 29 23:10:53 2011 -0500
second commit
commit 54832381a6fe898408c9e07bc8409a2982ec6274
Author: David Adams <[email protected]>
Date: Wed Jun 29 22:20:04 2011 -0500
changed checklist.php
commit 1955664689313a589543576477e0a134f26cc313
Author: David Adams <[email protected]>
Date: Wed Jun 29 22:12:53 2011 -0500
first releventz commit
David-Adamss-MacBook-Pro:releventz davidadams$ cd
David-Adamss-MacBook-Pro:~ davidadams$ cd
David-Adamss-MacBook-Pro:~ davidadams$ cd /applications/mamp/htdocs/releventz
David-Adamss-MacBook-Pro:releventz davidadams$ git status
# On branch master
nothing to commit (working directory clean)
David-Adamss-MacBook-Pro:releventz davidadams$ git status
# On branch master
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: application/libraries/calendarclass.php
#
no changes added to commit (use "git add" and/or "git commit -a")
David-Adamss-MacBook-Pro:releventz davidadams$ git add .
David-Adamss-MacBook-Pro:releventz davidadams$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: application/libraries/calendarclass.php
#
David-Adamss-MacBook-Pro:releventz davidadams$ git commit -m 'blah blah'
[master 853232d] blah blah
1 files changed, 1 insertions(+), 1 deletions(-)
David-Adamss-MacBook-Pro:releventz davidadams$ git push flashdrive master
Counting objects: 17, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (12/12), done.
Writing objects: 100% (12/12), 1.89 KiB, done.
Total 12 (delta 8), reused 0 (delta 0)
Unpacking objects: 100% (12/12), done.
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 t
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing int
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 som
remote: error: other way.
remote: error:
remote: error: To squelch this message and still keep the default behaviour, se
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.
gTo /volumes/thumbdrive/repo/releventz
! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '/volumes/thumbdrive/repo/releventz'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
韦斯提供了两个很好的答案。另一个解决方案是创建第二个分支。转到您的源存储库并签出第二个分支。您现在可以从工作存储库推送到主分支。
后续推送您可以替换为
Wes has offered two good answers. Another solution is to create a second branch. Go to your source repository and checkout the second branch. You can now push to the master branch from you work repository.
Subsequent pushes you can replace with
另一种选择是不在闪存驱动器上拥有完整的非裸(甚至裸)存储库(因为它涉及确保大量文件正确复制到闪存驱动器上)远程存储设备),但要拥有或更新捆绑包。
git 包是一个文件(通过 USB 驱动器复制更容易)。
您可以从该文件中提取内容,以便在您需要的任何地方重新创建一个完整的存储库。
请参阅“如何同步两个 git 存储库”作为说明。
Another option is to not have the full non-bare (or even bare) repo on the flashdrive (because it involves being sure that a lot of files are properly copied on a remote storage device), but to have or to update a bundle.
A git bundle is one file (much easier to copy over an USB drive).
And you can pull from that one file, in order to recreate a full-fledged repo anywhere you need to.
See "How to synchronize two git repositories" as an illustration.
不允许您推送到已签出代码的另一个存储库。 Git 拒绝更新它。
如果您确实需要闪存驱动器上的备份存储库并且您永远不会编辑其中的内容,那么请将其设为裸存储库。
如果您将其用作编辑内容的第二个位置,请进入该存储库并从基于磁盘的存储库中提取内容。 IE,始终拉到活跃使用的存储库中,而不是推送。
[是的,你可以解决这个问题,但你不应该]
You're not allowed to push to another repository that has checked out code. Git is refusing to update it.
If you really need a backup repo on the flash drive and you'll never edit things in it, then make it a bare repo instead.
If you are using it as a second location to edit things, then go into that repo and pull from your disk-based one instead. IE, always pull into an actively used repository, and never push.
[yes you can get around this, but you shouldn't]
今天我遇到了同样的错误。我用比尔·门的回答这样的方法修复了它。
也许你可以这样做:
Today i had the same error.and i fix it whit method like Bill Door's answer.
Maybe you can do like this: