What does the git error mean "pathspec did not match any file(s)"

14,029

I think you might've forgotten the step

$ git add .gitignore

before trying to commit, or then you mistyped, when you shoud've given

$ git commit -m "Add credentials.yml to .gitignore"

Process advised is highly dangerous [for the repo contents], so one must be really careful to follow all the steps in detail.

Share:
14,029
Andy Harvey
Author by

Andy Harvey

Updated on June 04, 2022

Comments

  • Andy Harvey
    Andy Harvey almost 2 years

    In a Rails app I realised I had committed a sensitive file config/credentials.yml to the git repo.

    In an effort to tidy things up I followed the advice on GitHub and ran

    git filter-branch --index-filter 'git rm --cached --ignore-unmatch config/credentials.yml' --prune-empty --tag-name-filter cat -- --all
    

    and then added to gitignore

    echo "config/credentials.yml" >> .gitignore
    

    When I try to commit these changes

    git add .gitignore
    git commit -m "ignored credentials.yml"
    

    I'm getting a message

    error: pathspec 'adds credentials.yml to gitignore' did not match any file(s) known to git.
    

    How can I fix this error? Or, how can I undo my changes and safely revert to the git history on my remote?