Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Thursday, 8 March 2012

Ignore files from Git

I've created my hello project and want to put it into Git.  All the online tutorials I read start with the same commands when creating a project:

git init
git add .

However, doing this will result in adding files and directories I do not want to commit. Fortunately, you can setup exclusions with git. There are several ways to do exclusions.  I used the method of adding a global exclusion file:

git config --global core.excludesfile ~/.global_ignore

This command sets up a global exclude file named ".global_ignore". So, any project I setup with git will use the exclusions I define in that file.

Here is what is in my .global_ignore file:

#generic files to ignore
*.DS_Store

#Java files
*.class
*.jar
*.war
*.ear

#Maven
target/

#IntelliJ
*.iml
*.idea

Now, when the "git add ." command is run, only my source files are marked for addition.

# On branch master
#
# Initial commit
#
# Changes to be committed:
#   (use "git rm --cached ..." to unstage)
#
# new file:   README
# new file:   pom.xml
# new file:   src/main/java/foo/bar/HelloWorld.java
# new file:   src/main/webapp/WEB-INF/web.xml
# new file:   src/main/webapp/index.jsp


References:
http://man.cx/gitignore - MAN page for gitignore
https://github.com/github/gitignore - A collection of useful .gitignore templates
http://help.github.com/ignore-files/ - GitHub's help page for gitignore

Monday, 5 March 2012

Git Git Git

I want to set up version control for my little project as well.  Over the years I've used Visual Source Safe, StarTeam, and  Subversion.  For this project I'm going to use Git.

Why?

  • I haven't used Git before, and it seems to be a popular VCS choice these days.
  • I want to share my final project and GitHub provides free hosting for public projects.  
  • Xcode prompts you to setup your project in Git.  
So, Git it is!

I followed the steps on GitHub and found the to be pretty straight forward.  http://progit.org/book/ch1-3.html has a good overview of what Git is and how it works.  I didn't follow the installations steps on that site though.  I just went to the Git site and downloaded it, setup was easy.

Well, I got everything setup on GitHub next step will be to get my project setup and committed!