From Game Making Tools Wiki

Help using git!



Kinda in usage order?

git status
Ask git what files need to be sent-off.
git branch
Ask git to list all the branches, and indicate the one you're working on.
git add [path]
Tell git to add changed file to be sent off to repo.
git commit -m "[message]"
Commit all files in staging and add a message describing the changes.
git push origin [branch]
Send your changed to the git repo., where [branch] is the name of the branch you're working on. Use master for the main one, otherwise the name is up to you!


Repo / Repository

Setting-up A New Repository


We do this via the command line. So open a terminal, or cmd if you're using Windows.

  1. git config [username] to add your username (can be whatever), and
  2. git config [emailaddress] to add the E-mail address you use to log-in to Github.
  3. (If you want to add SSH or GPG keys you should generate them now and add them via the web interface).
  4. Move to the directory where you'll be keeping your project.
  5. git init to initialise the repo.
  6. Create a readme file and a .gitignore file.
    • Your readme can be plain text or markdown, and should have a little info about the project. You'll have seen a bunch if you've visited Github, they're shown by default when you view a repo's page.
    • The gitignore file tells git what you don't and/or do want included in your repository. For example you don't want to make private data like address books and SSH keys public!
  7. git status will tell you what files you need to send-off to your repo.
  8. git add . adds everything in your work directory to the queue to go to the repo (called staging). Instead of using a . you can do it for individual files by entering their location.
  9. git commit -m "[message]" where [message] is a brief description of what you're changing.
  10. Next you'll need to do some stuff in your browser. Go to Github and create a new empty repository, then find and copy the 'remote repository URL'.
    (You can do this from the CLI too, but you have to use Github's API and it's kinda clunky)
  11. git remote add origin [remote repository url] to add the location.
  12. git push origin master will send off all your changes D:

Meta Files

You can add certain dotfiles (filenames that start with a dot, they're a Unixy thing) to tell git to do certain things with your project. The most common is .gitignore, which tells git to ignore certain files and folders in your working directory.

It's a little bit fiddly to make dotfiles on windows, but you can do so in the command prompt. Either:

  • NUL> .gitignore to create a new file.
  • REN [existing file] .gitignore to rename a file you've already made.

To open a command prompt at your current location in Windows Explorer just type cmd and hit Enter in the location bar. You can jump to the location bar quickly with either F4 or Alt+D


The .gitignore file is a list of files and directories that will not be uploaded to Git.

They can live multiple places, so you can exlude things globably, or per-project.


# comment

I like to start mine with /* which excludes everything, then tell it exactly what I do want added by prefacing the file and directory names with a ! Ignoring everything first, rather than ignoring everything individually was just the method that involved less typing :) Different methods work better depending on your project and how you set up your directories :)


Specific useful things to ignore


So for Unity game you probably want to ignore those .pdb files.

#	Visual Studio / Unity

#	Temp files


I just use the .editorconfig so when people view the files through Github's web interface the tabs look right, but you can set other stuff like line ending and character encoding in there too. Not sure if these files work with git generally. They are also common in text editors, perhaps the one you're using :)


root = true

indent_style = tab
indent_size = 4

The [*] is specifying which files to apply the arguments too (so you can enter specific extensions with, say:


See Also


See Also