Search code examples
gitcommitatlassian-sourcetree

How do I stop a failed to open stream error when committing via source tree


I Tried to perform a commit on my current branch using source tree and noticed whilst this was starting the commit process that I included a file i did not want to commit. So I clicked cancel. Now each time I commit I get a failed to open stream error on COMMIT_EDITMSG. Git thinks that the file is not present in the directory but it is.

I've tried performing a commit in git bash separately from source tree but this has not worked. I've tried deleting the branch entirely and i've tried reverting to the development branch, then creating a new branch.

When I try to commit, this is the error that I get:

In Filesystem.php line 26:

  SplFileInfo::openFile(./.git/COMMIT_EDITMSG): failed to open stream: No suc
  h file or directory


git:commit-msg [--git-user GIT-USER] [--git-email GIT-EMAIL] [-h|--help] [-q|--quiet] [-v|vv|vvv|--verbose] [-V|--version] [--ansi] [--no-ansi] [-n|--no-interaction] [-c|--config [CONFIG]] [--] <command> <commit-msg-file>

I'm expecting the commit to process and to successfully complete, however I experience the above error each time I perform any commits.

When I look at the contents of COMMIT_EDITMSG I find that it contains the commit message I am trying to add and nothing else.

I've checked that the file is not in a read only state and it isn't

How do I revert COMMIT_EDITMSG back to a usable state?


Solution

  • Found out what was causing the issue, I was looking in /.git instead of /laravel/.git. Found that COMMIT_EDITMSG was missing from /laravel/.git, so copied it from /.git to /laravel/.git, re-committed and this has fixed the issue.