Unity to Github Repository Issue

I am working on a project in Unity and am using Unity version control. I want the project to sync with a GitHub repository, but the issue is that I created the project before I created the GitHub repo. Using the feature of Unity version control, when I revert to a previous changeset, the files in the project folder revert back to that changeset. I have been manually copying files from the local Unity project to the GitHub repository to push them, but I feel this is not an efficient method.

To make the repo sync with the project folder, I tried the following:

First, I moved the .git folder from the GitHub repo to the Unity folder. Unfortunately, this did not work. I have not redone it, and now all versions after this contain the .git file, and somehow, the .git is no longer a hidden file. I suspect this might have complicated the problem, and I am not sure if I can delete this file or not.

After that, I tried copying all the Unity files (except for the .git file) to the repo, then opened the repo folder in Unity using the Add feature (instead of creating a new project).

When I used the original project folder to do this, I encountered directory conflicts similar to those described in this forum post: Unity Forum: Stuck solving directory conflicts .


I tried to resolve the conflicts, but some of the files could not be resolved and caused unexpected errors, such as “Collection was modified; enumeration operation may not execute.”

Next, I downloaded the latest changeset from Unity version control. I could load the project successfully, but there are several issues in both GitHub and Unity version control.

In the GitHub repo, I encountered multiple issues:

  • When trying to pull: “cannot open .git/FETCH_HEAD: Permission denied.”
  • When trying to push: “Git error: Unable to append to .git/logs/refs/remotes/origin/master: Permission denied.”

In Unity version control, if I use a folder that is not the GitHub repo folder (i.e., just a copy of the latest changeset), whenever I revert to a previous changeset, I get this message: “Can’t get new changes (Incoming Changes) because you need to check in the current merge first. You can check in changes to a new branch or alternatively merge from the last changeset of the current branch.”


Occationally, I also get unexpected errors.

At this point, it seems my approach is definitely correct. But it appears that if I don’t revert to a previous changeset, I don’t encounter these errors, and I should be sticking with my original method.

However, I was wondering what the solution to this problem might be. If anyone knows how to resolve this, I would be grateful for your input.