4

I have recently started using the vim-fugitive plugin, and currently I am facing problem with the Gpush command.

I tried :Gpush % which gives me errors in the quick fix window saying

fatal: could not read from remote repository
make sure you have the correct access rights

I can push from outside vim (the terminal) without any problems.

Do I need extra configuration? or are there other arguments when executing :Gpush command?

I have already tried going through the help file via :h fugitive and could find any clue. Please help.

8
  • :Gpush % feels incorrect. Can you :Gpush without any arguments? Aug 22, 2019 at 17:50
  • I have tried that too, vim stops responding as if something is happening in the background, I can't do anything afterwards, except killing the process and then restarting vim.
    – Imran Ali
    Aug 22, 2019 at 17:57
  • @PeterRincker is correct: the command is :Gpush. If there is background processing, it’s usually vim running git push (though with dispatch this can be off-loaded). I suspect there’s something else going on
    – D. Ben Knoble
    Aug 22, 2019 at 18:12
  • @D.BenKnoble, is there any diagnostic command to figure out whats wrong and troubleshoot the problem?
    – Imran Ali
    Aug 22, 2019 at 18:18
  • 1
    Is your remote using https? It seems as though it may be waiting for credentials and not properly prompting for them. Maybe try switching the remote to use ssh.
    – janders223
    Aug 22, 2019 at 18:58

2 Answers 2

4

I rarely ever run :Gpush on its own, so maybe try this:

:Gstatus

in the new split view, use - to toggle which changes you want to stage for the commit, then use cc to commit.

After entering the commit message and save/quit, the split window shows unpushed commits; you can use - to push individual commits. The exact push line and parameters are shown in the command line to be confirmed.

YMMV - I'd be curious what you make of this workflow.

1
  • 2
    Cool. I've been using fugitive for a while, and didn't know that. How do you even know that - pushes individual commits? I couldn't find it anywhere in the docs. Oct 3, 2019 at 19:23
3

Quote from vim-fugitive README:

FAQ Why can't I enter my password when I :Gpush?

It is highly recommended to use SSH keys or credentials caching to avoid entering your password on every upstream interaction. If this isn't an option, the official solution is to use the core.askPass Git option to request the password via a GUI. Fugitive will configure this for you automatically if you have ssh-askpass or git-gui installed; otherwise it's your responsibility to set this up.

As an absolute last resort, you can invoke :Git --paginate push. Fugitive recognizes the pagination request and fires up a :terminal, which allows for interactive password entry.

So, in your case, there are two possible solutions:

  1. Use :Git --paginate push
  2. Switch to ssh and authenticate with a key
1
  • I'm getting the same error even with the SSH key configured.
    – gayashanbc
    Jun 8, 2021 at 8:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.