.gitignore and Getting Ready for Github

One important thing most of the git guides ignore is .gitignore (note the name: DOT gitignore). The .gitignore is just a file that lists all the files that git should ignore, that is, should never commit. Mostly these will be files that are auto-generated by your source code (like .class files in Java). Your git repo should not contain any files that are generated by your compiler/ide, except for a few exceptions. The .gitignore file resides on your root directory and is checked into git.

During the next month, I recommend everyone follow the following steps to make sure they can get git+github+gitignore+ide working together well:

  1. Use a hello-world app you've built.
  2. Google "your-plaftform gitignore" (for example: "android gitignore" or "asp.net gitignore") to find a a good starting .gitignore file to add to your project. Some nice IDEs now add this file this automatically. If you are on a Mac you will also need to google "mac gitignore" and add those too. There might be more things you need to add. Add the .gitignore file to the root folder of your project.
  3. Add your app to git using your IDE. Generally, you will want to use the git commands from your IDE.
  4. On your web browser, go to github.com and create a temporary github repo on your account.
  5. Push you app to this repo. This will mean setting your IDE for pull/pushing to github.
  6. Check to see that the files appeared in github. <small celebration/>
  7. Close your IDE project.
  8. Clone your github project as a new project, in a different directory. Some IDEs support this (File->Import From Github or somesuch), but for others you will have to "git clone ..." or use the github desktop client.
  9. Make sure you can compile and run the new project. <small celebration/>
  10. Make a small change to your source code, compile and run, then git-commit the change and git-push to github.
  11. Look at your commit in github. It should show only the change you made to the one file. If it says that other files were changed then (likely) those files need to be added to .gitignore. If not, then <large celebration/>

While you are there, also play around with creating a branch from your IDE (name it after your github username), and then switching between this branch and the master branch. Make the two have different code. Compile both.

If you have any problems, drop by my office or setup a time with me or Bridgette.