There are many reasons to use a repository to store your work. Foremost, it's simply the smart thing to do:
• Keeps you from losing work
• Makes it easy to collaborate
• Easy to use (once you begin to learn how to use Source Tree)
• It's free
*A little background to help you read the instruction*
Remote and Local
Think of a repository as a remote folder that stores a snapshot of the software. You copy that snapshot by cloning it to your workspace, and then you can make your changes within your workspace without having to worry about breaking anything within the remote folder. After you’re satisfied with the changes, you can update the snapshot with your changes. It is a very simple concept that is used to share a snapshot among several team Members. Commands
There are a few basic commands you use in order to interact with the repository. These are the basic commands we will use to work with our repository:
• Clone copies the files into the local environment.
*think of it as downloading
• Pull copies the files into your machine for processing. *think of it as downloading but different.
• Push copies the changes in the local environment into the server copy.
*think of it as uploading
• Merge combines the differences between what you have and what is currently in the snapshot
• Stage prepares files to be uploaded to the repository
Environment
In order to save your work in a repository, you will need the following:
1. An account with a source-code repository. In this case https://gitlab.com/ ca (it's free)
2. Source Tree: https://www.sourcetreeapp.com/ (free software for your desktop created by Atlassian)
3. Your Unity game or software that you want to store "in the cloud"
Instructions
Create a repository
navigate to your home page on gitlab
select New Project
type a new project name
select Create Project
Clone the repository to your desktop
Navigate to the project home on Gitlab
Select Clone
Copy the Clone with https text
Open Source Tree application on your desktop device
Click Clone on your home menu
Paste the https text taken from step 3 into the clone address field (the top field)
Select an empty folder where you want to store the project
Give it a name
Select Clone
Add custom .gitignore for your Unity game
For many reasons, you don't need to store all of the files on your local machine into the server. Because of this, there is a file named .gitignore. It is a configuration file that tells git to stop tracking files, so they won't need to be stored on the server. Git ignores files and the .gitignore text you see below is the configuration for Unity projects. Copy and paste the contents below to your .gitignore file as per the instructions:
Inside the folder, you configured with Source Tree, create and edit an empty text file
Copy and paste this text below and save
# begin copy and paste this into a .gitignore where your project resides # 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/ /[Uu]ser[Ss]ettings/ # MemoryCaptures can get excessive in size. # They also could contain extremely sensitive data /[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 # Packed Addressables /[Aa]ssets/[Aa]ddressable[Aa]ssets[Dd]ata/*/*.bin* # Temporary auto-generated Android Assets /[Aa]ssets/[Ss]treamingAssets/aa.meta /[Aa]ssets/[Ss]treamingAssets/aa/*
Store your changes to the repository for the first time
Stage, Commit and Push
Select Working Copy under File Status
In the middle panel, select stage all
In the text field, type in your comment
Select commit
Select Master
Select Push
Check master
Select Push
Create the development branch
This creates a copy that everyone should download when they access this repository. You will copy this version to your workspace in following steps
Under remotes, open the caret and right-select master - checkout origin-master
Name the branch Development*
Select OK
Create your workspace branch
Under Branches, select DevelopmentBranch you created in the last step
Select Branch
Name the new branch LocalBranch
Select OK
Make a change in your workspace
Select LocalBranch
Go to your project on your local environment and make a change. *In this example, I simply create a folder and a text file in the project.
Commit your changes to prepare upload: Step 1
*Stage and Commit
Select Working Copy
Select Stage All
Type in a comment
Select commit
Merge changes to prepare upload: Step 2
double-click the Development Branch
select Merge
Select the Local Branch, select OK
Copy contents to the server Step 3: Push
Select Push
Select Development Branch
Ensure that the remote branch is also DevelopmentBranch Select Push
Congratulations! You've just created your first repository. Edit and follow the above steps and never, ever lose your work!
Comments