這是場景。我有兩臺機器,「桌面」和「筆記本電腦」。如何讓兩個git存儲庫保持同步?
在桌面上我做的:
mkdir git_test
cd git_test
git init
dd if=/dev/urandom of=test.img bs=1k count=1000
git add test.img
git commit -m "Added first image"
然後在筆記本電腦,我做的事:
git clone [USER]@desktop:/home/[USER]/git_test
cd git_test
dd if=/dev/urandom of=test2.img bs=1k count=1000
git add test2.img
git commit -m "Added second image"
然後我想我的桌面上的混帳回購協議看起來像我的筆記本電腦的混帳回購協議。在筆記本電腦上,我發出以下命令: 混帳推起源主
但後來我得到:
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'.
如何保持這兩個回購同步?
錯誤消息似乎暗示git有我想要的功能,但出於某種原因,它似乎是一個更高級的工作流程。我聽到有人曾經說過,你不能推到你現在所在的分支,有人能說這是一個可能的解決方案嗎?我對這種性質的解決方案沒有任何問題,例如,我可以在我的筆記本電腦上的某個分支上工作,並在我的桌面上處理另一個分支上的問題,然後以某種方式同步它們,使它們完全相同。
請注意以下事項!
我不想使用集中式回購,像github上,有幾個原因。首先是安全。第二個是簡單。第三是由於情況我不會進入這裏,我不能指望有一個互聯網連接到一些遠程服務器,我只有我的兩臺機器通過局域網連接。最後,我想學習如何按照我在這裏所要求的方式來做事,以獲得特定的知識。
我也不想使用裸回購,因爲裸回購在根目錄中有一堆垃圾。這是醜陋和混亂。我從顛覆轉向git的全部原因是,git看起來像是一個更清潔,分散的解決方案。另外,我還有一些非技術人員會在桌面的根目錄中工作,他們會被這個問題困惑不解。 git的美妙之處在於(我認爲)所有東西隱藏在.git文件夾中。編輯:顯然,我不清楚這一點。想象一下,我有一個「Documents」文件夾,其中包含以下子文件夾:mydata1和mydata2。這不是一個人爲的例子,這正是我想要處理的問題。 mydata1應該包含「test.img」,只有這個文件,而是它現在有:
分支 配置 描述 HEAD 鉤 信息 對象 裁判
我希望能夠只需cd到mydata1並開始編輯文件,但是我必須嘗試通過分支機構cd,或者甚至只是爲了完成工作。並且對於這種類型的目錄結構,每個子文件夾在「文檔」中是不可行的。請不要告訴我這樣做。請回答這個問題。謝謝。
這兩點是整個原因我在這裏發佈這個問題。請只回答如果你有這個問題的答案。 :) 謝謝!!
我指的是「cruft」,如下所示:「分支配置說明HEAD掛鉤信息對象引用」我只想/ home/[User]/git_repo只包含我正在使用的文件。另外:.git文件夾被隱藏。 –
您可以隱藏回購。 – nobar