Last updated by 1 year ago
Page: Checking Projects into SVN, Version:16
Checking Projects into SVN or GitAuthor: Marc PalmerAuthor: James LorenzenTable of Contents
- Creating a new project and putting it into SVN
- Fixing an existing project that is already in SVN
- Checking out from SVN
- Adding a new project to Git
- web-app/WEB-INF/classes/ - common if you use Eclipse or STS
.classpathfiles. These files are required by Eclipse and STS to function. Even if you do not use Eclipse or STS, someone else who wants to check out the project may. Ignoring these files in your SCM will make it very difficult for Eclipse and STS to recognize the project.
Creating a new project and putting it into SVNThis approach is for use when starting a new Grails project - i.e. it does not yet exist on your disk at all, nor in SVN. It will talk you through your first check in, including the relevant svn:ignore properties, and avoids any check in of these ignored files that may or may not exist locally.With SVN installed, create your project. We will use "MyProject" as the name for the purposes of demonstration:
Now you must create an empty SVN directory under your SVN repository using whatever appropriate tools you have. This directory should be called the same as MyProject but it doesn't have to be. We will call this SVN repository directory path "emptysvndir" for this example.Note: The WEB-INF instructions below are optional. If you perform those steps, you must run "grails upgrade" after checking out your repository.Next you do:
grails create-app MyProject cd <projname>
That should have your project committed, and changes to ./plugins/core and ./web-app/WEB-INF/ should be ignored by SVN. You will not need to check out this project as we have used the "in place import" technique.Why is this such a hassle? Well SVN prevents files or directories being considered for version control by checking an "ignores" list that is set via an SVN property. This property is set on specific directories within your SVN working copy. Therein lies the problem - until you have a working copy you cannot tell it to ignore files.
svn checkout <svn-server-url>/emptysvndir/ . svn add * svn propset svn:ignore "WEB-INF" web-app/ svn propset svn:ignore "target" . svn rm --force web-app/WEB-INF svn rm --force target svn commit -m "First commit"
Fixing an existing project that is already in SVNThis approach is for use when you have optimistically imported your entire project into SVN already and have started getting errors or are being annoyed by the warning messages relating to locally changed files.We will use "MyProject" as the name for the purposes of demonstration:
That should have your project committed, and changes to ./plugins/core and ./web-app/WEB-INF/ should be ignored by SVN.
cd MyProject svn propset svn:ignore "WEB-INF" web-app/ svn propset svn:ignore "target" . svn rm web-app/WEB-INF svn rm target svn commit -m "Fixing SVN"
Checking out from SVNTo checkout this project fresh locally or on another machine you will need to checkout as usual but then run:
The grails upgrade command re-instates files we are not committing to the repository. This applies mainly to the files under WEB-INF/ dir: including applicationContext.xml, tld/* , sitemesh.xml , web.template.xml etc.
Adding a new project to GitTo check a project into git for the first time, use the following commands:
cd MyProject git init echo target >> .gitignore echo web-app/WEB-INF >> .gitignore git add . git commit -m "Initial commit"