Skip to content

git push upstream branch does not exist, wrong command recommended first #1207

Closed
@matthewarmand

Description

Recently I noticed a change in a thefuck behavior that I use very regularly which I wanted to call out as what I think is an unwanted change. This was introduced very recently, I believe with the 3.31 release. When using git push on a git repository where the branch does not exist in the upstream repository, git responds with a specific command one should run to create the upstream branch. Prior to version 3.31, thefuck seemed to recognize this and made the first suggested Corrected Command was the one git recommended. As of version 3.31, thefuck instead puts a generic git push --no-verify command first, and the one git recommended is instead the second result.

In this case where git recommends a specific command, git push --no-verify doesn't actually help or do what the user wants; you need the git push --set-upstream origin branch-name command which thefuck now arrives at second. Because of the inconvenience for this particular case, combined with the fact that the first option recommended by thefuck isn't functionally valid, the prior behavior is more correct for this particular case.

Below is all the debug information requested in the issue template:

The output of thefuck --version (something like The Fuck 3.1 using Python 3.5.0 and Bash 4.4.12(1)-release):

The Fuck 3.31 using Python 3.9.5 and ZSH 5.8

Your system (Debian 7, ArchLinux, Windows, etc.):

Arch Linux

How to reproduce the bug:

- In a git repo, create a branch which does not exist in the upstream repository
- Attempt to push the branch with `git push`
- You should see an error message saying "fatal: The current branch branch-name has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin branch-name"
- invoke `thefuck`
- Prior to 3.31, `thefuck` would present as the first option the exact command which git tells you to use (git push --set-upstream origin branch-name).
- As of 3.31, `thefuck` instead presents as the first option a more generic `git push --no-verify`, and git's recommended command is the second result.

The output of The Fuck with THEFUCK_DEBUG=true exported (typically execute export THEFUCK_DEBUG=true in your shell before The Fuck):

https://pastebin.com/qpyEcreC

If the bug only appears with a specific application, the output of that application and its version:

git version 2.32.0

Anything else you think is relevant:

N/A

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions