Error when pull or push to git: ENOENT: no such file or directory

21,011

Solution 1

I solved this creating the branch folder, in my case:

mkdir /home/projects/project_example/.git/refs/remotes/origin/branch_name

Solution 2

I encountered the same problem while trying to push to GitHub's private repo through VS Code on Mac (SSH with passphrase). Somehow it worked after creating a branch as posted by ZiTAL. It's weird though.

Share:
21,011
Jon Sud
Author by

Jon Sud

Updated on November 11, 2021

Comments

  • Jon Sud
    Jon Sud over 2 years

    I have a problem every time I want to do pull or push from my GitHub repo using vscode git throw error message:

    Error: ENOENT: no such file or directory, watch 'c:\repos\app-repo\.git\refs\remotes\origin\master'
    

    The repo is private in GitHub. In c:\repos\app-repo\.git\refs\remotes\origin I have one file called HEAD.

    What I should do? why this error happened?

    Here the full error from the vscode-git-output-control:

    git pull --tags origin master
    > git show :package.json
    From https://github.com/user/app-repo
     * branch            master     -> FETCH_HEAD
    > git status -z -u
    > git symbolic-ref --short HEAD
    > git rev-parse master
    > git rev-parse --symbolic-full-name master@{u}
    > git rev-list --left-right master...refs/remotes/origin/master
    > git for-each-ref --format %(refname) %(objectname) --sort -committerdate
    > git remote --verbose
    Failed to watch ref 'c:\repos\app-repo\.git\refs\remotes\origin\master', is most likely packed.
    Error: ENOENT: no such file or directory, watch 'c:\repos\app-repo\.git\refs\remotes\origin\master'
        at FSWatcher.start (internal/fs/watchers.js:164:26)
        at Object.watch (fs.js:1232:11)
        at Object.t.watch (c:\Users\user\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\git\dist\main.js:1:6950)
        at E.updateTransientWatchers (c:\Users\user\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\git\dist\main.js:1:97463)
        at u.fire (c:\Users\user\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:50:227)
        at T.updateModelState (c:\Users\user\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\git\dist\main.js:1:114843)
    > git show :package.json
    > git fetch
    > git show :package.json
    > git status -z -u
    > git symbolic-ref --short HEAD
    > git rev-parse master
    > git rev-parse --symbolic-full-name master@{u}
    > git rev-list --left-right master...refs/remotes/origin/master
    > git for-each-ref --format %(refname) %(objectname) --sort -committerdate
    > git remote --verbose
    Failed to watch ref 'c:\repos\app-repo\.git\refs\remotes\origin\master', is most likely packed.
    Error: ENOENT: no such file or directory, watch 'c:\repos\app-repo\.git\refs\remotes\origin\master'
        at FSWatcher.start (internal/fs/watchers.js:164:26)
        at Object.watch (fs.js:1232:11)
        at Object.t.watch (c:\Users\user\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\git\dist\main.js:1:6950)
        at E.updateTransientWatchers (c:\Users\user\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\git\dist\main.js:1:97463)
        at u.fire (c:\Users\user\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:50:227)
        at T.updateModelState (c:\Users\user\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\extensions\git\dist\main.js:1:114843)
    > git show :package.json