Setting Up Git For Unity
Once you’ve downloaded and installed Git onto your computer, Go to your Unity Project file and right click on it.
Select “Git Bash Here”.
Now you should see Git Bash open and display the aforementioned file name and its location in your file directory. Next you will be typing in a sequence of git commands in order to establish your GitHub repository and commit/push your work.
Type: “git init” to initialize your new repository.
Type: “git remote add origin” to add the repository to your local files.
Type: “git remote -v” to verify your link to the server.
[NOTE] Always (Pull, Commit, then Push) The order you do this in can affect the accuracy of your backup.
Type: “git — help” to have git display what commands you can use.
Type: “ git pull” to pull from the origin on the server.
Type: “git pull origin <branch name>” to pull any updates to the specified branch.
Type: “git branch” to see what branches are in your repository and which branch you’re currently in.
Type: “git status” to check the status of all files in the repository.
Type “git add <file name>” to include in what will be committed.
Type “git add .” to include all files into the commit.
Type “git commit -m “Type message here…” ” to commit to the branch and add a message to define the commit.
Type: “git push origin <current branch name>” to push commits to the origin of your current branch.
Type: “git branch <new branch name>” to create a new branch.
Type: “git switch <branch name>” to switch to the specified branch.
Type: “git merge <branch name>” to merge current branch with the specified branch.
Type: “git log” to see all commits made during this project. Type “Q” to get out of that screen.
after typing “git log”, type “git switch <insert commit #code here>” to revert your current branch back to the state it was during that specified commit.
[NOTE] The commits (#code) can be found in yellow letters beside the word commit after typing “git log”.
Type: “git — hard <insert commit #code here>” to commit your current branch back to the state it was during the specified commit.
And that’s it! With that information and a little practice, you now have the ability to use, navigate, and manage a GitHub Repository in teams or by yourself. Good luck and remember to check back for any updates and new posts.