2011-06-30 200 views
1

我有我的閃存驅動器上的本地工作副本回購和遠程回購。我已經推到閃存驅動器,但我似乎無法再次這樣做。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' 
+2

錯誤消息似乎足夠清晰。 – bmargulies

+0

[git push error'remote rejected \] master - > master(branch is currently checked out)']的可能重複(http://stackoverflow.com/questions/2816369/git-push-error-remote-rejected-master - 主分支 - 是 - 目前進行確認的鷗) –

回答

2

您不允許推送到檢出代碼的另一個存儲庫。 Git拒絕更新它。

如果您確實需要閃存驅動器上的備份回購,並且您永遠不會編輯其中的內容,那麼請將其設置爲裸回購。

如果您將它用作編輯事物的第二個位置,則進入該回購併從您的基於磁盤的存儲區取而代之。 IE,總是將拉到到一個積極使用的存儲庫,並從來沒有推。

[是你可以解決這個問題,但你不應該]

0

韋斯提供了兩個很好的答案。另一個解決方案是創建第二個分支。轉到您的源代碼庫並簽出第二個分支。您現在可以從您的工作存儲庫推送到主分支。

cd master_repo 
git checkout -b stepaside 
cd work_repo 
git push 

後續推動你可以替換

cd master_repo 
git checkout stepaside 
cd work_repo 
git push 
1

今天我有同樣的error.and我修復它絲毫方法像比爾·門的答案。 也許你可以這樣做:

David-Adamss-MacBook-Pro:~ davidadams$ cd /volumes/thumbdrive/repo/releventz 
David-Adamss-MacBook-Pro:~ davidadams$ git checkout subbranch 
David-Adamss-MacBook-Pro:~ davidadams$ cd /applications/mamp/htdocs/releventz 
David-Adamss-MacBook-Pro:~ davidadams$ git push flashdrive master 
0

另一種選擇是對閃存盤中的全部非裸露(甚至裸)的回購協議(因爲它涉及到是確保文件的很多正確地複製到遠程存儲設備上),但要具有或更新bundle

一個git捆綁包是一個文件(通過USB驅動器更容易複製)。
你可以從這個文件中取出,以便在你需要的任何地方重新創建一個完整的回購。
以「How to synchronize two git repositories」爲例。