Direkt zum Hauptbereich

Add an existing Grails project to Bitbucket using Git

I just started using Bitbucket as a new service to host masters of my source code repositories using Git. If you develop with Grails (like I also do more often) and ever asked yourself how to create a Git repository out of an existing project, here is the solution.

Prerequisits

Of course you need to have Git installt locally on your machine. If you haven't here are instructions on how to do it (if your a Mac user, I find this Mac OS X installer very useful). Of course you also need an account for bitbucket.org. It's free and easy to set up. In addition to your account you need to create an empty repository. Follow the guidance on the Bitbucket site, it's quite easy.

Prepare your grails project

As you do not want to store all your files in the repository, you need to create a so called .gitignore file. To do so, you can use a grails command:

> grails integrate-with --git

Afterwards, the .gitignore file has been created. If you are using the Grovy & Grails Tool Suite I propose to open the file in a text editor and to add the following line to it:

/target-eclipse/

Afterwards it should look like this (might differ on your side):

*.iws
*Db.properties
*Db.script
.settings
stacktrace.log
/*.zip
/plugin.xml
/*.log
/*DB.*
/cobertura.ser
.DS_Store
/target/
/out/
/web-app/plugins
/web-app/WEB-INF/classes
/target-eclipse/

Create a local repository

Now we can create a local repository. Open a terminal window and go to the root folder of your project. Initialize the local Git repository:

> git init

This will initialize the repository, a folder named .git is being create to store the repository. Now add and commit the .gitignore file to the repository and commit.

> git add .gitignore
> git commit -m "add .gitignore file"

The configuration what to store and what to omit is now being saved in the repo. You can add and commit all your project files now:

> git add .
> git commit -m "add initial project to repository

Great. If you want to see which files have been committed to the repo, type

> git ls-tree -r master

Upload to Bitbucket

Now you can upload your file to bitbucket. Set the bitbucket repo tho the remote origin of your local repo

> git remote add origin https://myname@bitbucket.org/myname/mynewrepo.git

Rem.: You can find your correct URL in the dashboard view of your repository in the bitbucket UI. You can also use SSH instead of https.



Last but not least commit your repo to bitbucket:

> git push -u origin --all

Et voila, you repository has been uploaded and you can use your newly created distributed infrastructure.

Kommentare

  1. Very nice and helpful tutorial. Could you please show how to push any updates in the project, after going through the steps you have nicely explained above. Thank you!

    AntwortenLöschen
  2. @ Tikeswar:

    once you've pushed the grails project to the bitbucket repo, you can handle it as you would do with any other git project, e.g.
    - adding new files to the local repo: git add .
    - committing to your local repo: git commit -m "my comment"
    - pushing to the remote repo: git push origin master
    The ".gitignore" files ensures that only the necessary files are pushed to the remote.

    AntwortenLöschen

Kommentar veröffentlichen

Beliebte Posts aus diesem Blog

CQRS - Command Query Responsibility Segregation

A lot of information systems have been built with a data manipulation focus in mind. Often CRUD (create, read, update delete) operations built on top of a predefined relational data model are the first functionalities that are implemented and lay out as a foundation for the rest of an application. This is mainly because when we think about information systems we have a mental model of some record structure where we can create new records, read records, update existing records, and delete records. This had been learned throughout the last decade of data centric and transaction oriented IT systems. This approach often leads to shortcomings when it comes to query and analyze the system's data. Classical layered architecture This is where CQRS comes into the game. CQRS stands for Command Query Responsibility Segregation and has been first described by Greg Young and later on by Martin Fowler. This architectural pattern calls for dividing the software architecture into two parts...

Creating load tests with Gatling instead of JMeter

I just came around a tool called Gatling (http://gatling-tool.org/) to create load tests for web applications. I used to use JMeter for a long time, but JMeter has weaknesses that Gatling doesn‘t have. JMeter uses a synchronous request approach. That means for every request JMeter generates, an internal thread is raised and therefore blocked until a response is being received or a timeout happens. This results in resource blocking on the load injector. The maximum number of threads is limited within a JVM - dependent on the underlying infrastructure -  and even if you are able to run a lot of parallel threads this will result in a high CPU and memory utilization. Although performance tweaking and scaling out to distributed testing might help in such a case, it makes testing more complex and error-prone. This behavior can result in distorted metrics. Think about a typical breakpoint load test. You want to determine, which is the maximum number of requests per second your tested ...