gitkraken / vscode-gitlens

Supercharge Git inside VS Code and unlock untapped knowledge within each repository — Visualize code authorship at a glance via Git blame annotations and CodeLens, seamlessly navigate and explore Git repositories, gain valuable insights via rich visualizations and powerful comparison commands, and so much more
http://gitkraken.com/gitlens
Other
8.96k stars 1.3k forks source link

Cannot pull or force push if local branch name differs from remote branch name #3327

Closed sodevel closed 4 months ago

sodevel commented 4 months ago

Description

Like the title says, i have a local branch named umaster that tracks the branch master on a remote, i cannot pull or force push that branch. However, a regular push does work.

GitLens Version

15.0.4

VS Code Version

Version: 1.89.1 (system setup) Commit: dc96b837cf6bb4af9cd736aa3af08cf8279f7685 Date: 2024-05-07T05:13:33.891Z Electron: 28.2.8 ElectronBuildId: 27744544 Chromium: 120.0.6099.291 Node.js: 18.18.2 V8: 12.0.267.19-electron.0 OS: Windows_NT x64 10.0.19045

Git Version

git version 2.44.0.windows.1

Logs, Screenshots, Screen Captures, etc

No response

axosoft-ramint commented 4 months ago

@sodevel This seems related to #3277. There is a fix for this currently in the pre-release version of GitLens - would you mind switching over to the pre-release and seeing if you can still repro the bug?

You can switch to the pre-release edition of GitLens by clicking on the "Switch to Pre-Release version of this extension" from the Extensions view.

image

sodevel commented 4 months ago

With that version pulling does work, but force-push still does not. The error message i receive sounds like it did a normal push, but the GitLens output channel shows a correct command line.

[2024-05-29 16:29:32.049] [GIT  ] [c:/git/xprivate/wxFormBuilder] git push --force-with-lease --force-if-includes upstream test/name-diff-diffed [*1021ms] (slow)
[2024-05-29 16:29:32.050] Git.push
Error: Unable to force push branch 'test/name-diff-diffed' to upstream because some refs failed to push or the push was rejected. The tip of the remote-tracking branch has been updated since the last checkout. Try pulling first.
axosoft-ramint commented 4 months ago

Thanks. Is the result of the force push (and the command output in that output channel) what you would expect to happen when force pushing in this particular case, or would you have expected it to succeed?

Does it work if you run the same command in a git terminal?

Trying to determine if it's just a messaging issue on the error output here or if it's a case of a force push failing that should have succeeded.

sodevel commented 4 months ago

Well, i do expect the force push to happen, but using the command line git push --force-with-lease --force-if-includes in a terminal does fail as well. Just using git push --force-with-lease does succeed but i don't understand why the other one doesn't. No one changed the remote refs in between, the state my side knows about the remote is absolute identical to the current remote state, so to my understanding the --force-if-includes is fulfilled.

axosoft-ramint commented 4 months ago

Hmmm, --force-if-includes also checks that the tip of the remote ref was 'integrated locally' - the push with this flag would fail if, for example, you had fetched but not checked out locally, some commits (i.e. applied them to your local history). Not saying that is the case here, but if it is, it would explain why the command fails. It is one of the gentlest forms of force push.

axosoft-ramint commented 4 months ago

Since I'm not seeing any further bugs here, going to close this issue as a duplicate of 3277. Feel free to open a new one if, for example, you would like us to add a version of push without --force-if-includes.

sodevel commented 4 months ago

Just a heads up, if i rename the local branch to the name of the remote branch the git push --force-with-lease --force-if-includes does succeed. For me this sounds like a bug in git, why should the name of the local branch matter?

github-actions[bot] commented 3 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.