Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

git remote rename origin upstream fails to fully rename #888

Closed
1 task done
AArnott opened this issue Sep 17, 2016 · 5 comments
Closed
1 task done

git remote rename origin upstream fails to fully rename #888

AArnott opened this issue Sep 17, 2016 · 5 comments

Comments

@AArnott
Copy link

AArnott commented Sep 17, 2016

  • I was not able to find an open
    or closed issue
    matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options
git version 2.10.0.windows.1
sizeof-long: 4
machine: x86_64
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
    Windows 10, 64-bit
$ cmd.exe /c ver
Microsoft Windows [Version 10.0.14393]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
    All defaults.
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt
Path Option: Cmd
SSH Option: OpenSSH
CRLF Option: CRLFAlways
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

No.

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

PowerShell

git clone https://github.com/Microsoft/vscode-languageserver-node.git
cd .\vscode-languageserver-node\
git remote rename origin upstream
git remote rename upstream origin

  • What did you expect to occur after running these commands?

Just one remote: origin
Also, if I add a git remote command in between the two renames, to see just one remote (upstream), but instead I see two (upstream and origin).

  • What actually happened instead?
fatal: remote origin already exists.
  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

It happens to all repos.

@shiftkey
Copy link

I've not been able to reproduce this with the same setup (Win10 14393, Powershell) on either the same build or the latest public release (2.11.0):

PS C:\Users\shiftkey\src\vscode-languageserver-node> git --version
git version 2.10.0.windows.1
PS C:\Users\shiftkey\src\vscode-languageserver-node> git remote -v
origin  https://github.com/Microsoft/vscode-languageserver-node.git (fetch)
origin  https://github.com/Microsoft/vscode-languageserver-node.git (push)
PS C:\Users\shiftkey\src\vscode-languageserver-node> $env:GIT_TRACE=1
PS C:\Users\shiftkey\src\vscode-languageserver-node> git remote rename origin upstream
14:53:57.835843 git.c:350               trace: built-in: git 'remote' 'rename' 'origin' 'upstream'
PS C:\Users\shiftkey\src\vscode-languageserver-node> git remote rename upstream origin
14:54:05.179284 git.c:350               trace: built-in: git 'remote' 'rename' 'upstream' 'origin'
PS C:\Users\shiftkey\src\vscode-languageserver-node> git remote -v
14:54:14.882547 git.c:350               trace: built-in: git 'remote' '-v'
origin  https://github.com/Microsoft/vscode-languageserver-node.git (fetch)
origin  https://github.com/Microsoft/vscode-languageserver-node.git (push)
PS C:\Users\shiftkey\src\vscode-languageserver-node>

@AArnott have you seen this since reporting this?

@AArnott
Copy link
Author

AArnott commented Dec 15, 2016

Yes. I still see this. I'm currently running git for windows 2.10.2.windows.1

@AArnott
Copy link
Author

AArnott commented Jan 16, 2017

My git configuration is as follows, in case that's relevant.

git config --list --global
alias.co=checkout
alias.ci=commit
alias.st=status
core.safecrlf=warn
core.preloadindex=true
core.fscache=true
core.autocrlf=true
push.default=simple
credential.helper=manager
user.email=andrewarnott@gmail.com
user.name=Andrew Arnott
remote.origin.prune=true
diff.tool=vsdiffmerge
difftool.prompt=true
difftool.vsdiffmerge.cmd="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\vsdiffmerge.exe" "$LOCAL" "$REMOTE" //t
difftool.vsdiffmerge.keepbackup=false
merge.tool=vsdiffmerge
mergetool.prompt=true
mergetool.vsdiffmerge.cmd="C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\vsdiffmerge.exe" "$REMOTE" "$LOCAL" "$BASE" "$MERGED" //m
mergetool.vsdiffmerge.trustexitcode=true
mergetool.vsdiffmerge.keepbackup=false
rebase.autosquash=true
rerere.enabled=true
gui.recentrepo=C:/git/roslyn

@AArnott
Copy link
Author

AArnott commented Jan 16, 2017

@jrbriggs identified the problem as my remote.origin.prune=true config setting. He advised I replace it with fetch.prune=true.
This eliminated the repro.

@AArnott AArnott closed this as completed Jan 16, 2017
@shiftkey
Copy link

@AArnott thanks for following up, and I'm glad you were able to get to the bottom of it!

dscho added a commit to dscho/git that referenced this issue Jan 17, 2017
One of the really nice features of the ~/.gitconfig file is that users
can override defaults by their own preferred settings for all of their
repositories.

One such default that some users like to override is whether the
"origin" remote gets auto-pruned or not. The user would simply call

	git config --global remote.origin.prune true

and from now on all "origin" remotes would be pruned automatically when
fetching into the local repository.

There is just one catch: now Git thinks that the "origin" remote is
configured, as it does not discern between having a remote whose
fetch (and/or push) URL and refspec is set, and merely having
preemptively-configured, global flags for specific remotes.

Let's fix this by telling Git that a remote is not configured unless any
fetch/push URL or refspect is configured explicitly.

As a special exception, we deem a remote configured also when *only* the
"vcs" setting is configured. The commit a31eeae (remote: use
remote_is_configured() for add and rename, 2016-02-16) specifically
extended our test suite to verify this, so it is safe to assume that there
has been at least one user with a legitimate use case for this.

This fixes git-for-windows#888

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
fengguang pushed a commit to 0day-ci/git that referenced this issue Jan 18, 2017
One of the really nice features of the ~/.gitconfig file is that users
can override defaults by their own preferred settings for all of their
repositories.

One such default that some users like to override is whether the
"origin" remote gets auto-pruned or not. The user would simply call

	git config --global remote.origin.prune true

and from now on all "origin" remotes would be pruned automatically when
fetching into the local repository.

There is just one catch: now Git thinks that the "origin" remote is
configured, as it does not discern between having a remote whose
fetch (and/or push) URL and refspec is set, and merely having
preemptively-configured, global flags for specific remotes.

Let's fix this by telling Git that a remote is not configured unless any
fetch/push URL or refspect is configured explicitly.

As a special exception, we deem a remote configured also when *only* the
"vcs" setting is configured. The commit a31eeae (remote: use
remote_is_configured() for add and rename, 2016-02-16) specifically
extended our test suite to verify this, so it is safe to assume that there
has been at least one user with a legitimate use case for this.

This fixes git-for-windows#888

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
dscho added a commit to dscho/git that referenced this issue Jan 19, 2017
One of the really nice features of the ~/.gitconfig file is that users
can override defaults by their own preferred settings for all of their
repositories.

One such default that some users like to override is whether the
"origin" remote gets auto-pruned or not. The user would simply call

	git config --global remote.origin.prune true

and from now on all "origin" remotes would be pruned automatically when
fetching into the local repository.

There is just one catch: now Git thinks that the "origin" remote is
configured, even if the repository config has no [remote "origin"]
section at all, as it does not realize that the "prune" setting was
configured globally and that there really is no "origin" remote
configured in this repository.

That is a problem e.g. when renaming a remote to a new name, when Git
may be fooled into thinking that there is already a remote of that new
name.

Let's fix this by paying more attention to *where* the remote settings
came from: if they are configured in the local repository config, we
must not overwrite them. If they were configured elsewhere, we cannot
overwrite them to begin with, as we only write the repository config.

There is only one caller of remote_is_configured() (in `git fetch`) that
may want to take remotes into account even if they were configured
outside the repository config; all other callers essentially try to
prevent the Git command from overwriting settings in the repository
config.

To accommodate that fact, the remote_is_configured() function now
requires a parameter that states whether the caller is interested in all
remotes, or only in those that were configured in the repository config.

Many thanks to Jeff King whose tireless review helped with settling for
nothing less than the current strategy.

This fixes git-for-windows#888

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
gitster pushed a commit to git/git that referenced this issue Jan 19, 2017
One of the really nice features of the ~/.gitconfig file is that users
can override defaults by their own preferred settings for all of their
repositories.

One such default that some users like to override is whether the
"origin" remote gets auto-pruned or not. The user would simply call

	git config --global remote.origin.prune true

and from now on all "origin" remotes would be pruned automatically when
fetching into the local repository.

There is just one catch: now Git thinks that the "origin" remote is
configured, even if the repository config has no [remote "origin"]
section at all, as it does not realize that the "prune" setting was
configured globally and that there really is no "origin" remote
configured in this repository.

That is a problem e.g. when renaming a remote to a new name, when Git
may be fooled into thinking that there is already a remote of that new
name.

Let's fix this by paying more attention to *where* the remote settings
came from: if they are configured in the local repository config, we
must not overwrite them. If they were configured elsewhere, we cannot
overwrite them to begin with, as we only write the repository config.

There is only one caller of remote_is_configured() (in `git fetch`) that
may want to take remotes into account even if they were configured
outside the repository config; all other callers essentially try to
prevent the Git command from overwriting settings in the repository
config.

To accommodate that fact, the remote_is_configured() function now
requires a parameter that states whether the caller is interested in all
remotes, or only in those that were configured in the repository config.

Many thanks to Jeff King whose tireless review helped with settling for
nothing less than the current strategy.

This fixes git-for-windows#888

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants