NeogitOrg / neogit

An interactive and powerful Git interface for Neovim, inspired by Magit
MIT License
4.07k stars 240 forks source link

Unable to stage hunk in other root directory #900

Closed ten3roberts closed 1 year ago

ten3roberts commented 1 year ago
          So this is still an issue actually. It seems like it goes hand-in-hand with #691.

Steps to produce:

  1. Open nvim inside a project where git is initialized that's not the root folder.

    In my case I would nvim open dotfiles/.config/nvim. But the root folder is the dotfiles

  2. Open up neogit
  3. Try hunk stashing a change.
  4. I get an error saying:
    
    git --no-pager -c color.ui=always --no-optional-locks apply --cached:
    error: packages/common/.config/nvim/../../../mac/Brewfile: does not exist in index

Open the console for details Git Error (1), press $ to see the git command history



What fixes the issue is opening nvim on the root folder where git is initialized. In my case, that's the `dotfiles/` folder. If you need more info let me know. I don't mind helping out the most I can.

_**SideNote: Just used `nvim-tree` to jump back up to my root folder and that worked as well. Granted that defeats the purpose since sadly I would've opened neovim there to begin with.**_

_Originally posted by @CarlosMed in https://github.com/NeogitOrg/neogit/issues/395#issuecomment-1773991615_
ten3roberts commented 1 year ago

Thank you for reopening the issue. I moved it to a new issue.

Is it only when hunk staging or file staging as well, as well as other git operations.