How to "version management"?

Whenever i work on programming projects i use git (duh) to do version control.

Of course i could “git init” my scripts folder, but that would not version-control my scenes and other assets.

I know unity teams is a very good version control but it costs $$ because it stores my project in some cloud. All i want is LOCAL version control. Without a remote. Just locally.

Of course i could just “git init” my whole Unity project but there sure are a lot of unnecesary files like cache-files that might have changing names (bad for .gitignore).
Adding insult to injury, unity might not pick up changes (like, when switching the branch, or rolling back) because it has a lot of stuff cached in memory)

Is there either some sort of native way to version-control a unity project or does unity provide a .gitignore?

GitHub actually provides a template .gitignore for Unity projects when you create a new repository:

# This .gitignore file should be placed at the root of your Unity project directory
#
# Get latest from https://github.com/github/gitignore/blob/master/Unity.gitignore
#
/[Ll]ibrary/
/[Tt]emp/
/[Oo]bj/
/[Bb]uild/
/[Bb]uilds/
/[Ll]ogs/
/[Mm]emoryCaptures/

# Asset meta data should only be ignored when the corresponding asset is also ignored
!/[Aa]ssets/**/*.meta

# Uncomment this line if you wish to ignore the asset store tools plugin
# /[Aa]ssets/AssetStoreTools*

# Autogenerated Jetbrains Rider plugin
[Aa]ssets/Plugins/Editor/JetBrains*

# Visual Studio cache directory
.vs/

# Gradle cache directory
.gradle/

# Autogenerated VS/MD/Consulo solution and project files
ExportedObj/
.consulo/
*.csproj
*.unityproj
*.sln
*.suo
*.tmp
*.user
*.userprefs
*.pidb
*.booproj
*.svd
*.pdb
*.mdb
*.opendb
*.VC.db

# Unity3D generated meta files
*.pidb.meta
*.pdb.meta
*.mdb.meta

# Unity3D generated file on crash reports
sysinfo.txt

# Builds
*.apk
*.unitypackage

# Crashlytics generated file
crashlytics-build.properties

That’s great! How is unity’s support for git?
Like, how does the editor behave when changing scene files via git?
It should technically track all asset changes, but what about scene files?

Like… inspector values, what gameobject has which scripts… scene hirachy…

Seems to work as you’d expect; I’ve not had any major issues with Git & Unity so far.

Scenes, prefabs, & other assets are all saved as YAML documents, which contains the hierarchy structure, GameObject/Component/Inspector field references, etc. Modifying anything in a scene, prefab, or other asset, is just modifying the values in their YAML documents.
As long as those documents are tracked under version control, you can commit/push/pull/merge/revert/etc. and Unity will update its assets automatically.

Of course they are tracked and updated when changing something in the editor.
But does unity notice when git changes the files?

But great to hear that it appearantly is working

Yes, when a file is changed outside of the editor, Unity will recognize it and display a message like this:
6430508--719315--upload_2020-10-18_14-54-27.png
And then the changes will be applied after clicking the “Reload” button.

As an example, if you create a new local branch, move an object’s Transform position in the scene, commit the change, and then checkout back to the previous branch, the object’s previous position will be set after clicking “Reload”.

1 Like

That’s great! thanks!

Using git with Unity is AWESOME. It does not require any integration: you just git-source-control the entire subdirectory and make sure you have a good .gitignore.

Commit early, commit often, the damage you prevent will be your own. :slight_smile:

1 Like

The man, the myth. Kurt Dekker, the man who single-handedly keeps this forum running :smile:
Thanks! I’ll be sure to git my next project!

1 Like