Home > Enterprise >  fatal: cannot update the ref 'head': unable to append to '.git/logs/head': inval
fatal: cannot update the ref 'head': unable to append to '.git/logs/head': inval

Time:11-13

When trying to commit a project to github, the commits fails with an error: fatal: cannot update the ref 'head': unable to append to '.git/logs/head': invalid argument. This is after properly initialising the directory and having a succesfull first push.

The important part of the fix: I am using OneDrive to keep the files in

CodePudding user response:

You should never use a cloud syncing service such as OneDrive to store a Git repository. There are a couple reasons for this:

  • First, cloud syncing services sync file by file, whereas Git relies on the entire repository being in a single state, so using these services can cause corruption due to leaving the repository in an inconsistent state. People have been known to lose data from doing this.
  • Git requires a file system that provides POSIX semantics, including the ability to append to files atomically. This is generally possible with a normal Windows file system, but many cloud syncing services use custom file systems that don't provide these abilities, so Git just won't work with them.

In this case, you're seeing the latter problem.

The best way to sync a repository across machines is just to push and pull to a remote, like GitHub. You can also use git bundle to transfer a bundle file using whatever method you like. Your final option is to sync between machines using rsync -a --delete-after (preferably using SSH), but you must make sure that the repository is completely idle when you're doing that, which also means that things like git gc and editor integrations aren't running. If it isn't, you can end up with corruption.

CodePudding user response:

The other solution:

  • do not clone anything in a OneDrive-sync'ed folder (as seen here)
  • push / pull as expected from a normal regular folder
  • create at any time a git bundle: it produces one file (representing the full repository content), see also here.

You can store one file in a backup drive.

CodePudding user response:

The solution:

Start OneDrive if it has not yet been started. After this you should be able to push succesfully

  • Related