Cannot push project to the Github (Permission denied)

Hello. I have used Github before and uploaded a few projects there without any issues. I am now working with Unity and creating my first game. I have initialized empty git repository and tried to stash all changes using command:
git add .
The error returned:

error: open("Temp/FSTimeGet-d34d1af5cef0bc44fbcba01a2fb5323c"): Permission denied
error: unable to index file 'Temp/FSTimeGet-d34d1af5cef0bc44fbcba01a2fb5323c'
fatal: adding files failed

I have tried to look the error up on the google but could not find anything relevant. Perhaps anybody had some simillar issues and could suggest something? Thanks in advance.

You should ignore Temp folders.

Here is the .gitignore I use for Unity and I add more as needed.

9564631–1352797–gitignore.zip (626 Bytes)

I have tried your .gitingore and I can confirm that it fixed the issue. Thank you.

Additionally, what about other directories that you ignore (such as Library). Is that not necessary if you want to share your project with others ?

Definitely not necessary. Definitely CRITICAL that you get it right from the start.

If you ever (even once) commit any of those files they will remain tracked until you git rm them from the repo.

Be sure you’re set up correctly before compounding previous errors. Here’s some notes:

PROPERLY CONFIGURING AND USING ENTERPRISE SOURCE CONTROL

I’m sorry you’ve had this issue. Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.

Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.

As far as configuring Unity to play nice with git, keep this in mind:

https://discussions.unity.com/t/736093/3

I usually make a separate repository for each game, but I have some repositories with a bunch of smaller test games.

Here is how I use git in one of my games, Jetpack Kurt:

https://discussions.unity.com/t/807568/3

Using fine-grained source control as you work to refine your engineering:

https://discussions.unity.com/t/826718/2

Share/Sharing source code between projects:

https://discussions.unity.com/t/719810/2

Setting up an appropriate .gitignore file for Unity3D:

https://discussions.unity.com/t/834885/5

Generally the ONLY folders you should ever source control are:

Assets/
ProjectSettings/
Packages/

NEVER source control Library/ or Temp/ or Logs/
NEVER source control anything from Visual Studio (.vs, .csproj, none of that noise)

Setting git up with Unity (includes above .gitignore concepts):

It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It’s simply ridiculous not to back up.

If you plan on joining the software industry, you will be required and expected to know how to use source control.

Source control does require learning, but there are TONS of tutorials and courses and online reference.

You should strive to use source control as confidently as you use your file/folder system.

“Use source control or you will be really sad sooner or later.” - StarManta on the Unity3D forum boards

No. Everything in the Library is cache. It can be recreated from things in Assets folder and packages folder. If you’re working alone and you don’t expect to change this, you may want to include the UserSettings, since that are settings per user and in theory don’t affect the project itself, only the Editor for the current user. In general what is in my .gitignore is safe to ignore.

Note that GitHub, when creating a new repository, gives you the option to select a .gitignore from a list. There’s a Unity specific .gitignore that you should pick.

@Lurking-Ninja

Hey. Please let me clarify something!
I have cloned the repository on my another machine:

and imported the project to Unity. The project contains Scripts, Spirtes, Palletes and other things that I have created but the scene is emtpy:

Perhaps there are some filles missing in the repository ?

Scroll down to the part on scene is empty:

Lost progress / project / work / stuff disappeared in Unity.

This article is to help you when you have lost significant progress or work in your Unity project.

It is designed to give you avenues of discovery and investigation.

It is NOT a guarantee of restoring your lost work. It is NOT a substitute for proper IT / Data security procedures.

To decide which parts are applicable to you, look for major bolded headings.

EVERYTHING IS GONE, YOU CANNOT OPEN THE PROJECT

Your project probably is still on your computer. Try a computer-wide search for some unique filenames that you know are in the project you think is gone.

To start your search, one common file to all Unity projects is named ProjectSettings.asset

Some things that might have happened:

  • you are not opening the project that you think you are
  • you are in the correct project but not opening the same scene you had open before
  • you dragged the project (or part of it) into the trash (intentionally or inadvertently)
  • you moved the project (or part of it) somewhere else (intentionally or inadvertently)
  • an overly-aggressive antivirus solution quarantined it because it saw code being compiled in there
  • you’re using a directory sync like OneDrive or Dropbox… NEVER USE THESE SERVICES WITH UNITY!
  • something else??

As I said, it’s probably still all on your system to be found if you look in the right places.

A typical Unity project will have at a minimum the following folders:

ProjectSettings\
Packages\```

**EVERYTHING IS PRESENT BUT MY SCENE WINDOW IS BLANK**

Close Unity and make a full project backup RIGHT NOW. Do not do ANYTHING else until you back it up 100%.

Ideally copy that backup to another computer, or back it up to another external hard drive entirely. This is just basic data processing best practices during data recovery operations.

If you can see all the files and folders of your project, make sure you are opening the scene file you were working in.

Once you have opened the scene, look in the hierarchy window, select an object and move the mouse over the Scene window and press F to focus that object.

Additional notes:

- ALWAYS use proper industrial grade source control (see below)
- NEVER use Dropbox or any file sync mechanism in Unity.
- NEVER move files within your project, except by doing it within Unity
- ALWAYS be sure you are fully backed up before upgrading Unity

**SCRIPTS OR ASSETS ARE MISSING OR BLANK**

ALWAYS move all Unity assets by using the Unity Editor. Any other way risks disconnecting the GUID in the meta file from the original file, and this will result in all connections to that asset being broken.

Some info about Missing script warnings, broken prefabs, GUIDs, renaming GUIDs, etc:

https://discussions.unity.com/t/836322/2
https://discussions.unity.com/t/815173/7
https://discussions.unity.com/t/815173/9

EVERYTHING in Unity is connected to the above GUID, which is stored ONLY in the metafile, and hence why the metafiles ALWAYS MUST be source-controlled.

**When Renaming**: It is super-easy to inadvertently change the GUID by renaming outside of Unity. Don't do that. Instead:

- close Visual Studio (important!)
- rename the file(s) in Unity
- in Unity do Assets -> Open C# Project to reopen Visual Studio
- now rename the actual classes, and MAKE SURE THE FILE NAMES DO NOT CHANGE!

If you are NOT using source control while you do this, renaming files is an EXTREMELY dangerous process. Use source control at all times so that you can trivially revert if you miss a critical step and damage your project.

**UNITY CRASHES / FREEZES WHEN I OPEN MY PROJECT**

You must isolate if there is something wrong with your Unity installation, something wrong with your project, or perhaps just a corrupted import or asset database.

First, ALWAYS back your project up. Then try deleting the ```Library/``` and ```Temp/``` folders that are within your project, the directories that are peers to the ```Assets``` and ```ProjectSettings``` folders.

If that doesn't work it is time to bisect. Make a new empty project and get Unity to open that. If you cannot then it is time to fix your Unity installation, either by fully reinstalling or verifying it with the hub.

Once you have an empty project open, begin copying over your project. Try the entire thing. If it crashes, try half of the project, then the other half, etc.

As always, if you're using Windows, another thing to try is to simply reboot the system. This often fixes typical Windows issues related to locked files and locked directories.

**ISSUES RELATED TO UPGRADING PROJECTS (eg, changing to a higher Unity version)**

Upgrading to a later version of Unity is a one-way process. Any project that has been updated should NEVER be reverted to an earlier version of Unity because this is expressly not supported by Unity. Doing so exposes your project to internal inconsistencies and breakage that may actually be impossible to repair.

If you want to upgrade to a newer version of Unity, do not even consider it until you have placed your project fully under proper source control. This goes double or triple for non-LTS (Tech Stream) versions of Unity3D, which can be extremely unstable compared with LTS.

Once you have source-controlled your project then you may attempt a Unity upgrade. Immediately after any attempted upgrade you should try to view as much of your project as possible, with a mind to looking for broken animations or materials or any other scripting errors or runtime issues.

After an upgrade you should ALWAYS build to all targets you contemplate supporting: iOS and Android can be particularly finicky, and of course any third party libraries you use must also "play nice" with the new version of Unity. Since you didn't write the third party library, it is up to you to vet it against the new version to make sure it still works.

If there are issues in your testing after upgrading Unity, ABANDON the upgrade, revert your project in source control and be back where you were pre-upgrade with the earlier version of Unity.

Obviously the less you test after the upgrade the more chance you will have of an undiscovered critical issue.

This risk of upgrading is entirely on you and must be considered whenever you contemplate a Unity version upgrade.

Do not upgrade "just for fun" or you may become very unhappy.

**ISSUES RELATED TO GOING BACK OR UNDOING BREAKING CHANGES TO YOUR WORK**

Keep in mind that Unity does NOT back your files up. That's on YOU.

Use either version control (see below) or else make your own backups.

[quote="zazas321, post:7, topic: 937009, username:zazas321"]
Perhaps there are some filles missing in the repository ?
[/quote]

Certainly possible. Only you know. See these same notes for how to achieve success:

(reposting)

**PROPERLY CONFIGURING AND USING ENTERPRISE SOURCE CONTROL**

I'm sorry you've had this issue. Please consider using proper industrial-grade enterprise-qualified source control in order to guard and protect your hard-earned work.

Personally I use git (completely outside of Unity) because it is free and there are tons of tutorials out there to help you set it up as well as free places to host your repo (BitBucket, Github, Gitlab, etc.).

You can also push git repositories to other drives: thumb drives, USB drives, network drives, etc., effectively putting a complete copy of the repository there.

As far as configuring Unity to play nice with git, keep this in mind:

https://discussions.unity.com/t/736093/3

I usually make a separate repository for each game, but I have some repositories with a bunch of smaller test games.

Here is how I use git in one of my games, Jetpack Kurt:

https://discussions.unity.com/t/807568/3

Using fine-grained source control as you work to refine your engineering:

https://discussions.unity.com/t/826718/2

Share/Sharing source code between projects:

https://discussions.unity.com/t/719810/2

Setting up an appropriate .gitignore file for Unity3D:

https://discussions.unity.com/t/834885/5

Generally the ONLY folders you should ever source control are:

Assets/
ProjectSettings/
Packages/

NEVER source control Library/ or Temp/ or Logs/
NEVER source control anything from Visual Studio (.vs, .csproj, none of that noise)

Setting git up with Unity (includes above .gitignore concepts):

https://thoughtbot.com/blog/how-to-git-with-unity

It is only simple economics that you must expend as much effort into backing it up as you feel the work is worth in the first place. Digital storage is so unbelievably cheap today that you can buy gigabytes of flash drive storage for about the price of a cup of coffee. It's simply ridiculous not to back up.

If you plan on joining the software industry, you will be required and expected to know how to use source control.

Source control does require learning, but there are TONS of tutorials and courses and online reference.

**You should strive to use source control as confidently as you use your file/folder system.**

"Use source control or you will be really sad sooner or later." - StarManta on the Unity3D forum boards

I don’t see anything other than the default Unity sample scene in the repository.

@Kurt-Dekker

I have a backup and I can open the project without any issues on my main PC.

Its just when I clone repository via Github and import it to the Unity it does not automatically generate the Scenes for some reason

git is just another tool and it has to be debugged.

Look in the repo, were the scenes committed?

Commit a new scene, clone again. Does that show up?

This stuff DOES WORK, don’t just throw up your hands. Try to debug it.

It is here:

https://github.com/krupis/My_first_platformer/tree/main/Assets/Scenes

It contains all information about my Scene (Floor, Player) and etc but is not imported when I open the project

Great! Go look in the repo. Are the scenes present in the list of committed files?

I don’t use the Github desktop client but google knows how to search up files in your repo.

You’ve committed and pushed to the repository?

I had to drag and drop the Scenes to my Hierarchy:

I was under the impression that the main scene was going to open up automatically

Unity opens the last scene but it doesn’t automatically open up multiple scenes which is what you’re doing by dragging a scene into the Hierarchy nor does it treat any of those scenes as the last scene. Instead it’s seeing whichever you last opened by either File → Open Scene or double clicked in Assets.

If no scenes have been opened in that manner it will default to a new scene which is what’s happened in your screenshot.

Nope. Unity could / would only do so by storing some data about what that scene was.

That would be a bad thing to commit to source control (again and again, just based on what you were editing at the last minute before you committed) so Unity doesn’t store such a thing where it is source controlled.

What scene you are staring at is NOT an important part of your project. The scenes are listed in critical order within the Editor Build Settings.

I imagine if you wanted you could make an Editor script that opens Scene #0 every time you launch the project… there’s probably already one out there you could find.

King of the Hill!!! ty