Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What means remote=. in GIT config?

Tags:

git

I'm not sure how (branch created with EGit, probably) I ended with this section in my config:

[branch "master"]
    remote = origin
    merge = refs/heads/master
[branch "sfc"]
    remote = .
    merge = refs/heads/master
    rebase = true

I would like to understand this. I'm not sure if the dot in remote = . is interpreted as url (current directory) or a special repository name (alias to myself)? Is that legal/normal/typical, or should I guess that this is messed up? It look strange to me to have a "remote" spec that points to the same repository. Furthermore, that branch indeed exists in the remote... What would be the implicancies of this regarding push/pull behaviour?

Some more info:

$ git remote show origin
* remote origin
  Fetch URL: ssh://[email protected]/var/gitrep/zzz.git
  Push  URL: ssh://[email protected]/var/gitrep/zzz.git
  HEAD branch: master
  Remote branches:
    master tracked
    sfc    tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local refs configured for 'git push':
    master pushes to master (fast-forwardable)
    sfc    pushes to sfc    (up to date)

$ git branch -vv
* master     f394d8b [origin/master: ahead 1] Bla blah...
  sfc        8065309 [master: behind 89] Bla blah...
like image 698
leonbloy Avatar asked Jul 22 '13 17:07

leonbloy


2 Answers

Git will resolve this as a relative path, just like ../../some/other/repo. As such it will resolve the directory of the repository itself. As your remote merge target is master, running git push while sfc is checked out, will simply try to fast-forward master to sfc.

You can create branches like that by running

git branch --set-upstream somebranch

Maybe that’s what you did, because you forgot to set a remote branch as starting point.

like image 136
Chronial Avatar answered Sep 28 '22 19:09

Chronial


That is quite strange. I went ahead and created a dummy repo, changed .git/config to make a remote be ., added some code, committed, and pushed.

$ git checkout weird
$ touch nothing
$ git add nothing
$ git commit -a -m "test"
[sup 031541e] test
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 nothing
$ git push
fatal: The upstream branch of your current branch does not match
the name of your current branch.  To push to the upstream branch
on the remote, use

    git push . HEAD:master

To push to the branch of the same name on the remote, use

git push . weird

$ git push . weird
Everything up-to-date

It appears to be hitting the repository locally, which of course means that a push results in git saying it's up to date.

like image 32
Kyle Kelley Avatar answered Sep 28 '22 18:09

Kyle Kelley