Pushing a Unity Project to Github
After some preliminary preparation, local work can be placed onto https://github.com for team access. Branches may also be created for work during development.
At the remote Github site, complete information for project name, which will be the repository name.
After setting .gitignore template to Unity, checking read access to Public, and whether or not to begin with a README.md file, make a note of the main branch url.
On the local workstation, create a new Unity project with name and location, including Unity Cloud access if desired.
With the remote awaiting and the local project available, open a terminal to connect to the remote Github repo.
cd <”location of empty project folder”>
git init
git remote rm origin (if the origin is already set)
git remote add origin <url>
git fetch origin
Initially, git may warn of LF CR/LF changes when adding project files, and output a verbose list of files in the project.
git add . (a decimal point wildcare char) This does not work with Visual Studio, so add (git add…) each directory individually.
git commit -m “message to explain circumstances of commit”
and then the final step. This should create a prompt for a github login:
git push origin main
or “git push origin master”
After a refresh, the coordinated project files appear on the remote Github main branch.
Now from this entry point with a local empty git project matching the remote Github main branch files, new branches may be created separating development according to function.
git branch
git branch dev
git branch
git switch dev
git branch
git branch inventory
git branch quest
git switch dev
— -< add a c# script devBranch > — -
git add .
git commit -m “Added Dev Script”
git switch inventory
git merge dev
— -< add a c# script inventory > — -
git add .
git commit -m “Added inventory script”
git switch dev
git merge inventory
git init
git push origin dev
— — — — < revert prior verion > — — —
git log
<q>
<highlight copy id hash of prior version>
git switch idhashofpriorversion
— — — -< revert to prior version as a branch > — — — -
git switch -b old-project-state idhashofpriorversion
— — — < revert to prior version of main > — —
git reset — hard idhashofpriorversion
git push — force origin master