2009-06-27 50 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会将所有新修改的文​​件添加到您的所有新文件中,然后提交;这在当前版本中已得到纠正,但我仍然不完全相信这件事。