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
No comments:
Post a Comment