Thefuck is incorrectly adding the remote name at the end of the command suggestion:
$ git push myfork
fatal: The current branch test-branch has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream myfork test-branch
$ fuck
git push --set-upstream myfork test-branch myfork [enter/↑/↓/ctrl+c]
error: src refspec myfork does not match any.
error: failed to push some refs to '[email protected]:waldyrious/project-foo.git'
Thanks for the report, I've been experiencing this as well! It looks like git_push is the relevant rule here: https://github.com/nvbn/thefuck/blob/629056077f3d9c4055821736e9a3479e38c91584/thefuck/rules/git_push.py
I'm having this problem too; but it's not obvious to me how to fix it. The function blindly takes any arguments given to git push and appends them to git's suggestion. The simple case would be to just use the suggestion provided by git, and ignore any extra arguments you added, since you have no real context.
For example, the following commands might both lead to git suggesting a correction, but only the second would result in a valid git command if the extra arguments were appended to git's suggestion.
git push myfork
git push --verbose
To be pragmatic (and because I very rarely use any extra arguments to git push) I added a local rule, which just returns git's suggestion verbatim. It's far more useful to me, than trying to be clever, and failing!
@davidhart82, would you mind posting the local rule you've added? We might be able to simply use it instead of the current one. I'd be happy to handle the PR myself, if you just show your code.
@josephfrazier, sure, since I see your commit doesn't solve some of the edge cases.
I realized that simply using the git suggestion might not include any additional options the user passed, since I'm not sure if the git suggestion accounts for those. Could you elaborate on the edge cases?
The current tests just aren't complete enough, but do hint at the cases which aren't covered. For instance:
git push --quiet origin still returns an incorrect result.
Also, the new test you've added, should have been:
git push origin and not git push master
I solved the problem by returning a list containing 2 possible corrections. The first was as originally coded, and the second was git's suggestion verbatim. I wasn't sure I could return 1 suggestion that was right in all circumstances.
Most helpful comment
I'm having this problem too; but it's not obvious to me how to fix it. The function blindly takes any arguments given to
git pushand appends them to git's suggestion. The simple case would be to just use the suggestion provided by git, and ignore any extra arguments you added, since you have no real context.For example, the following commands might both lead to git suggesting a correction, but only the second would result in a valid git command if the extra arguments were appended to git's suggestion.
git push myforkgit push --verbose