2009-06-27 51 views
12

我經常需要開發的東西的道路上,沒有互聯網/網絡連接。我只是一個單一的開發人員,所以到現在爲止,我只是有我的機器上的SVN倉庫,做了結帳我的筆記本電腦時,我走了。問題:這使我無法在道路上進行源控制。混帳設置單個開發者?

所以我嘗試了改變,以混帳,這似乎做我想做的,但我不知道我的理解正確它應該如何在我的設置中使用。

本質:

  • 創建使用git init
  • 克隆使用git clone
  • 該倉庫機器1克隆該庫以機2使用git clone
  • 曾爲\ MYSERVER \共享\項目資源庫上機2臺,使用git commit承諾我的本地庫
  • F所列的變化inally使用git push推的所有更改到\ MYSERVER \共享\ prohect
  • 機1上使用的git pull擺脫\ MYSERVER \共享\項目的最新變化

這樣的作品,但git push命令給了我警告說不支持推出檢出分支,因爲它可能會混淆索引。現在,我很困惑,因爲信息也是用嚴肅的語氣寫成的,這意味着我應該尊重它(事實上,gitk表明我現在有兩個分支:master和remotes/origin/master),但是我還沒有完全理解術語。

什麼將是我的情況正確的步驟?

  • 我會計算機1或計算機2上只有永遠的工作,不必在兩個
  • 我打算用分支的方式來對錯誤修正/測試一個單獨的分支(就像在通常的方式),但不是讓多個開發人員的方式
  • 我真的主要想用它來替代rsync我的SVN。

編輯:有兩個古怪。第一個是如果我簡單地更改文件,它會顯示「已更改但未更新」。這是奇怪的:

# On branch master 
# Changed but not updated: 
# (use "git add <file>..." to update what will be committed) 
# (use "git checkout -- <file>..." to discard changes in working directory) 
# 
#  modified: myproject/Readme.txt 
# 
no changes added to commit (use "git add" and/or "git commit -a") 

第二條消息是一個我認爲是罪魁禍首,混帳推的輸出:

warning: You did not specify any refspecs to push, and the current remote 
warning: has not configured any push refspecs. The default action in this 
warning: case is to push all matching refspecs, that is, all branches 
warning: that exist both locally and remotely will be updated. This may 
warning: not necessarily be what you want to happen. 
warning: 
warning: You can specify what action you want to take in this case, and 
warning: avoid seeing this message again, by configuring 'push.default' to: 
warning: 'nothing' : Do not push anything 
warning: 'matching' : Push all matching branches (default) 
warning: 'tracking' : Push the current branch to whatever it is tracking 
warning: 'current' : Push the current branch 
Counting objects: 7, done. 
Delta compression using up to 4 threads. 
Compressing objects: 100% (4/4), done. 
Writing objects: 100% (4/4), 333 bytes, done. 
Total 4 (delta 3), reused 0 (delta 0) 
Unpacking objects: 100% (4/4), done. 
warning: updating the current branch 
warning: Updating the currently checked out branch may cause confusion, 
warning: as the index and work tree do not reflect changes that are in HEAD. 
warning: As a result, you may see the changes you just pushed into it 
warning: reverted when you run 'git diff' over there, and you may want 
warning: to run 'git reset --hard' before starting to work to recover. 
warning: 
warning: You can set 'receive.denyCurrentBranch' configuration variable to 
warning: 'refuse' in the remote repository to forbid pushing into its 
warning: current branch. 
warning: To allow pushing into the current branch, you can set it to 'ignore'; 
warning: but this is not recommended unless you arranged to update its work 
warning: tree to match what you pushed in some other way. 
warning: 
warning: To squelch this message, you can set it to 'warn'. 
warning: 
warning: Note that the default will change in a future version of git 
warning: to refuse updating the current branch unless you have the 
warning: configuration variable set to either 'ignore' or 'warn'. 
To file:///\\myserver\share\project 
    129649b..1f4b957 master -> master 

所以它告訴我,「推進當前的分支」是不推薦,但我真的不明白這樣做的正確方法。

+0

我使用git來解決同樣的問題。我不是有同樣的問題,但我有點不同。我在家使用一臺linux服務器作爲中央存儲庫,然後我所有的開發地點都是中央的克隆。你能複製確切的錯誤信息嗎?這可能會幫助我更好地回答你的問題。 – 2009-06-27 14:11:41

+0

這有幫助。你有幾個很好的答案,來自其他人,我正在投票。 – 2009-06-27 15:06:31

回答

10

否則看起來不錯,但爲了避免出現錯誤消息,您可以將「上游」存儲庫設置爲空回購,即不包含已檢出副本的存儲庫。爲此,您可以

git --bare init 

e.g. this example

+1

感謝您的鏈接,包含我想要的!這個「魔術」是首先創建一個本地存儲庫,然後將其推送到服務器上的一個--bare存儲庫,而不是相反。 – 2009-06-27 16:30:55

8

git push命令需要你指定的Refspec,否則你將不得不編輯.git/config指定被指定在沒有refspecs的情況下,默認操作。例如,考慮您擁有名爲master的分支的情況。

對於推動master分支,你會:

git push refs/heads/master:refs/heads/master 
git push master:master 
git push master 

所有上述的相同。看起來像路徑的refspec是指定refspec的最明確的方式。這樣,您可以確定您指的是名爲master的分支,而不是名爲master的標籤。

否則,您可以編輯.git/config並添加:

[push] 
    default = matching 

這將允許你只git push,和Git將推動當地的分公司您當前所在的遠程分支,比如,如果你目前在分支master,git push會將本地主分支推送到遠程主分支。

正如janneb所述,您將不得不使用裸存儲庫來推送它,而不會發出警告。推送到一個普通(而不是空白)存儲庫的問題是,(特定`正常'存儲庫的)主要所有者不會想要將更改添加到他/她的存儲庫中。那時候,如果有人推送到這個存儲庫,並刪除一個分支(或任何其他更改),則所有者不會預期這種更改。因此,警告。

0

你似乎有很好的解答您的主要問題,所以我會解決這個:

...如果我只是修改一個文件,它說:「改變,但不更新」。這是奇怪...

Git的,不像所有其他版本控制系統不斷,需要明確的用戶採取行動,包括在一套東西接下來將要提交修改的文件。你不得不說

$ git add <your modified files> 

編輯它們和git commit之前。我的印象是這樣可以更容易地選擇性地提交一些修改。

如果你做了「git add」然後修改這些文件,你必須再次執行「git add」,否則它只會提交更改到第一個「git add」的位置。

有一個快捷方式,git commit -a,它或多或少地做了其他VCS的「提交」操作。我說「或多或少」,因爲我不確定它在所有情況下都完全匹配。我知道唯一的分歧是,一些較舊版本的git會將所有新修改的文​​件添加到您的所有新文件中,然後提交;這在當前版本中已得到糾正,但我仍然不完全相信這件事。