Using GitBash with GitHub & Unity
First, set up a repository at Github in order to connect your account with the Unity project.
If you haven’t already create a new Unity project and call it “MyProject”
In the Git Editor, Type in cd(change directory) + ”unity projects” and press Enter.
→ Navigate to your ‘MyProject’ Folder.
If your unity project files are under a different directory you can run the command “cd X(drive location):”.
When we run the command “ls” again, the Editor should look like the following.
→ To initialize the Git repository run the command “git init”.
→ At Github, Copy the project clone link to your clipboard.
→ In the Git Editor you can now run the command
“git remote add origin (URL to your project)”
to check if the connection is established run the command “git remote -v”
We now have permission to pull and fetch from or to the remote server.
→ Now to pull from the main repository run the command
“git pull origin master”
We have now established a connection with GitHub.
→ Run the command “git status” to see which files are untracked (red) and tracked (green). Only tracked files will be added to the repository.
→ To track the files we want to push to the repository, run the command “git add .” or “git add (“Filename”)”.
→ To commit any changes you’ve made, run the command “git commit -m”commit description” ”.
→ Next run the command “git push origin master”.
→ Run the command “git branch” to list the available branches in the repository
You can now make changes to your unity project, collaborate and share it with the rest of the world! Note: for larger files LFS needs to be activated which is a command line extension for managing large files with Git.