开发者

"Cannot read git config" when configuring Git default remote and merge

I´m using EGit with eclipse to sync my dev environment to two different computer. I have a slight problem with the one where I originally created by project and pushed it to my remote git repo (which happens to be github开发者_如何学C).

Now I searched the web and found some pointers indicating that I have to add to key/value pairs myself to the config file. The keys are branch.master.merge and branch.master.remote

My config now looks like this:

[core]
repositoryformatversion = 0
filemode = false
logallrefupdates = true
autocrlf = false
[remote "origin"]
url = https://dan-lind@github.com/dan-lind/prime-sweet.git
fetch = refs/heads/master:refs/remotes/origin/master

The info I found was to add the follwing lines:

branch.master.merge = refs/heads/master
branch.master.remote = origin

Question: Where am I supposed to put them? I tried putting them both under the core and under the remote sections, but as soon as I fire up Eclipse I get an error message saying that the git config file cannot be read. If I remove the two lines again, everything is fine (except that I still have no defaults and cannot use pull)

Any suggestions? Cheers!


You have to put theses informations in this way in your config file:

[branch "master"]
    remote = origin
    merge = refs/heads/master

But you shouldn't have to edit this file manually. There are different ways to make git configure this tracking for you :

  • When you clone a remote repository, the tracking of the master branch is automatically configured
  • When you create a local branch, you can specify the tracking with the "--track" option :

git branch local --track origin/local

  • If you push a branch with the "-u" option, it will enable the tracking between your local branch and the remote you pushed to :

git push -u origin master


The branch.master translates to a section called [branch "master"]. So you get:

[branch "master"]
remote = origin
merge = refs/heads/master

Another option is to use the config command of git:

git config branch.master.remote origin
git config branch.master.merge refs/heads/master
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜