2012-06-19 40 views
1

我正在嘗試建立工作流程來創建新項目,並設置舊版本的項目通過Git進行版本控制。除了一步之外,最終都是有道理的。當我創建一個新項目時,初始化Git並執行初始提交,然後執行git clone --bare ./myproject //myserver/myshare/myproject.git。然後我設置了一個遙控器,git remote add origin //myserver/myshare/myproject.git。這些似乎工作正常。但是,當我做git branch -a時,它沒有顯示遠程存在主分支。git clone --bare不包含分支主文件

我現在正在解決這個問題的方法是,我只是git clone //myserver/myshare/myproject.git到一個不同的位置,並且遠程已經建立,並且主分支存在於遠程。我不知道有什麼可能是錯的,特別是因爲唯一的區別似乎是遙控器設置的方式。

在此先感謝!

回答

2

沒有錯。從git clone手冊頁:

--bare 
     Make a bare GIT repository. That is, instead of creating <directory> and placing the administrative files in <directory>/.git, make the <directory> 
     itself the $GIT_DIR. This obviously implies the -n because there is nowhere to check out the working tree. Also the branch heads at the remote are 
     copied directly to corresponding local branch heads, without mapping them to refs/remotes/origin/. When this option is used, neither remote-tracking 
     branches nor the related configuration variables are created. 

裸存儲庫不映射master提交指針refs/remotes/origin/master,但他們沒有。裸回購是vital when setting up remotes that others might push to or pull from,,但they aren't where you do day-to-day dev work.這聽起來像你有一個origin。除非您正在設置另一個遠程設備,否則請使用git clone //myserver/myshare/myproject.git作爲本地存儲庫。

+0

你是說我現有的流程是正確的嗎?我認爲所有的合併和工作都應該在本地完成,但我希望// myserver成爲每個人都可以推動和拉動變化的集中式回購,並且我希望我們有分層的分支(主人正在發佈,然後是一個測試分支,在這個分支最終使它成爲主宰之前集成了這些功能 - 這些分支可以從回購中獲得)。感謝您的答覆。 – Ethan

+0

是的,如果你想讓'// myserver'成爲每個人都可以'push'或'pull'的集中式回購,你應該設置得很好。如果你想在它上面放置新的分支,將它們分支到你的本地倉庫並將它們推送到原點。例如。 'git結帳-B測試大師&& git推送原點測試' – Christopher

+0

聽起來不錯。再次感謝。 – Ethan