Showing posts with label git. Show all posts
Showing posts with label git. Show all posts

Monday, 12 January 2015

git branching model

Git Branching most of the time seemed like a maze to me. Specially while sending a Pull Request for sprint development.
When there are three features in a sprint,
1) One idea could be  - maintain three local branches for each feature and send three parallel PRs separately.
After feature gets merged, delete local and remote feature branches.

2) The other could be - maintain three local branches for each feature, but when finished merge them to one single branch and send a PR one by one or ?.


I think the second one restricts from having number of unwanted branches to be deleted later, which looks OK to me while working in a team. 

Here's how I implement this approach; assuming sprint/develop is an upto-date branch created with HEAD of master,

STEP 1 - create feature branch
git checkout -b module-1/feature-1 sprint/develop


STEP 2 - after feature completion
Merge it to single sprint/develop branch
git checkout sprint/develop
git merge --no-ff module-1/feature-1 # create a new commit object.

## delete the feature branch
git branch -d module-1/feature-1


STEP 3 - rebase sprint/develop branch with master
git rebase master ## if any conflicts occur, resolve them manually, git add conflicted files, and
                            ## git rebase --continue


STEP 4 - push develop changes
git push origin sprint/develop  ## or git push --force origin sprint/develop

STEP 5 - Send PR and get reviewed
Send PR for merge on master. what?? few implementation not aligned with architecture of codebase?? FIX them on same branch and push.

Friday, 23 November 2012

git cheat sheet I

[1] git color configuration
$ git config --global color.ui auto


OR add the following [color] content to ~/.gitconfig
$ vi ~/.gitconfig  


[color]
  diff = auto
  status = auto
  branch = auto
  interactive = auto
  ui = true
  pager = true
[diff]
     tool = vimdiff


[2] git incoming
#using git fetch
$ git fetch && git log ..origin/master --stat

##using git diff
$ git diff master origin/master

[3] display paths that have diffs between the index file and the current HEAD commit

$ git status

In emacs, same thing is achieved with M-! git status. The following screenshot is for emacs.




[4] git diff (with vimdiff)
create a file named git_diff_wrapper, put it somewhere in your $PATH
$ vi /usr/local/bin/git_diff_wrapper
#!/bin/sh
vimdiff "$2" "$5"

add following code to ~/.gitconfig

[diff]
  external = git_diff_wrapper
[pager]
  diff =

add following code to bash conf file
$ vi ~/.bashrc
function git_diff() {
  git diff --no-ext-diff -w "$@" | vim -R -
}

Now, its baked, fire following command
$ git diff 
$ git diff HEAD^ HEAD src/js  (with previous commit)
$ git diff HEAD~2 HEAD src/js (with 2 previous commits from HEAD)
$ git diff c3b8159 HEAD src/js (with sha-id)

If vim-fugitive is used, fire following command in opened file
:Gdiff -- %  # shows commits
:copen

To exit :qa

[5] git outgoing

$ git log origin/master.. --stat

OR

$ git fetch && git log origin/master.. --stat

OR (git whatchanged)


$ git whatchanged origin/master.. --stat


[6] git reset/rollback a commit

$ git reset --soft 'HEAD^' 
# How to undo the last Git commit?
# --soft would keep the changed files and keep them in the index as they were just before the changed commit

$ git rebase -i            
#git equivalent for hg rollback



[7] git merge from remote repo to local HEAD
Feature-NepalTweets is the branch in the following example; 
$ git stash 
#changes stashed can later be viewed with git stash show and recovered via git stash pop.
$ git pull origin Feature-NepalTweets
$ git stash pop
or 
$ git stash apply && git stash drop
$ git diff --name-only --diff-filter=U 
OR
$ git status --short | grep "^UU "
#Fix conflicts
$ git status --short | grep "^UU "
#add conflicted files using git add
#comit files
$ git commit -i grails-app/controllers/whotweetsnepal/NepTweetController.groovy -m "FIX:json" --author prayag.upd@gmail.com;
[NepalTweets 0d5bf9d] FIX:json

#Commit only modified files
$ git commit -a -m "FIX : ADD Staff on bootstrap assigning it a User, MAKE createdBy of Person nullable, ADD school to a user in controller, ADD getting schoolAccount via  logged in user in makeRegistration";

$ git push origin Feature-NepalTweets 
To https://github.com/iPrayag/WhoTweetsNepal.git
   ebe387f..0d5bf9d  NepalTweets -> NepalTweets


NOTE : The other method could be removing the locally changed files, if the changes are not important, and then firing git pull.

undo a git merge
Say you are in branch analytics/tracking-requests, merged changes from master.
But for some reasons you want to undo a merge before commit and push,
git reset --hard origin/tracking-requests
or 
git reset --merge ORIG_HEAD

[8] add git submodule
I am pointing repo facebook-android-sdk-3.0.1 at https://prayagupd@bitbucket.org/prayagupd/facebook-android-sdk-3.0.1.git to my app BirthdayForestGap.

prayag@prayag: BirthdayForestGap$ git submodule add https://prayagupd@bitbucket.org/prayagupd/facebook-android-sdk-3.0.1.git facebook-android-sdk-3.0.1.git

Cloning into 'facebook-android-sdk-3.0.1.git'...

Password for 'https://prayagupd@bitbucket.org':
remote: Counting objects: 165, done.
remote: Compressing objects: 100% (116/116), done.
remote: Total 165 (delta 44), reused 162 (delta 44)
Receiving objects: 100% (165/165), 565.66 KiB | 8 KiB/s, done.
Resolving deltas: 100% (44/44), done.



prayag@prayag: BirthdayForestGap$ ls -la
total 68
drwxrwxr-x 10 prayag prayag 4096 Mar 29 00:40 .
drwxrwxr-x  7 prayag prayag 4096 Mar 28 01:10 ..
-rw-rw-r--  1 prayag prayag 2273 Mar 28 01:00 AndroidManifest.xml
drwxrwxr-x  3 prayag prayag 4096 Jul 17  2012 assets
drwxrwxr-x  4 prayag prayag 4096 Mar 28 19:05 bin
-rw-rw-r--  1 prayag prayag  416 Jul 17  2012 .classpath
drwxr-xr-x  5 prayag prayag 4096 Mar 29 00:40 facebook-android-sdk-3.0.1.git
drwxrwxr-x  3 prayag prayag 4096 Mar 28 19:03 gen
drwxrwxr-x  9 prayag prayag 4096 Mar 29 00:40 .git
-rw-r--r--  1 root   root    226 Mar 27 13:53 .gitignore
-rw-rw-r--  1 prayag prayag  164 Mar 29 00:40 .gitmodules
drwxrwxr-x  2 prayag prayag 4096 Mar 28 00:56 libs
-rw-rw-r--  1 prayag prayag  781 Jul 17  2012 proguard-project.txt
-rw-rw-r--  1 prayag prayag  820 Mar 26 15:08 .project
-rw-rw-r--  1 prayag prayag  629 Mar 28 00:54 project.properties
drwxrwxr-x 11 prayag prayag 4096 Mar 24 22:26 res
drwxrwxr-x  4 prayag prayag 4096 Mar 28 01:02 src


[9] Recover file permissions

$ git diff -p -R \
    | grep -E "^(diff|(old|new) mode)"  \
    | git apply
OR 

add as an git alias (let's call it permission-reset)
$ git config --global --add alias.permission-reset '!git diff -p -R | grep -E "^(diff|(old|new) mode)" | git apply'


If you don't see any changes when modifying permission, you probably have a configuration in git which ignore file mode.


[core]
    filemode = false

If the above doesn't work, fire the following command manually
prayag@prayag:~/hacker_/doctorhere-servlet$ git config core.filemode false

Also check git-preserve-permissions.


[10] git log --graph
9.1 show file history with patch
$ git log --follow --all -p grails-app/controllers/eccount/StudentController.groovy


OR git short log with --patch
$ git log -p grails-app/controllers/eccount/StudentController.groovy


[11] git difftool
add [diff] section to ~/.gitconfig.

[color]
  diff = auto
  status = auto
  branch = auto
  interactive = auto
  ui = true
  pager = true

[diff]
     tool = vimdiff

OR 

$ git config --global diff.tool vimdiff

Diff a single file with following command
$ git difftool grails-app/conf/Config.groovy

For shortcuts, follow vimdiff commands.



References
Git 1 2 3 by Jordan Schatz,

My git gist, https://gist.github.com/iPrayag/4730500

Try git, http://try.github.io/levels/1/challenges/1

http://git-scm.com/documentation

Git asks me to commit or stash changes on checkout master, even though all changes were commited?,  http://stackoverflow.com/a/13204493/432903

Change commit author at one specific commit, http://stackoverflow.com/a/3042512/432903

25 Tips for Intermediate Git Users, http://andyjeffries.co.uk/articles/25-tips-for-intermediate-git-users

https://github.com/jerith666/git-graph

Git error on commit after merge - fatal: cannot do a partial commit during a merge, http://stackoverflow.com/a/8062976/432903

is it possible to `git status` only modified files?, http://stackoverflow.com/a/13479518/432903

Git: how to diff the same file between two different commits on the same branch?

http://stackoverflow.com/a/5741436/432903

Sunday, 4 November 2012

Hacking on grails 2.1.2 and mysql

Part A : INSTALLATION
STEP 1 :
METHOD 1 : Download and move stable version of grails-2.1.1.zip to appropriate folder
prayag@prayag:~$ wget http://dist.springframework.org.s3.amazonaws.com/release/GRAILS/grails-2.1.1.zip
prayag@prayag:~$ sudo mkdir /opt/grails
prayag@prayag:~$ sudo mv /home/prayag/Downloads/grails-2.1.1.zip /opt/grails/

prayag@prayag:~$ cd /opt/grails/

prayag@prayag:/opt/grails$ sudo unzip grails-2.1.1.zip 


Confirm packages inside /grails folder,
prayag@prayag:~$ cd
prayag@prayag:~$ ls -l /opt/grails/grails-2.1.1/
total 100
drwxrwxr-x  2 prayag prayag  4096 Nov 30 15:24 bin
-rw-r--r--  1 prayag prayag 11258 Sep 12 10:27 build.gradle
-rw-r--r--  1 prayag prayag    22 Sep 12 10:27 build.properties
drwxrwxr-x  2 prayag prayag  4096 Nov 30 16:14 conf
-rw-r--r--  1 prayag prayag  7171 Sep 12 10:27 dependencies.txt
drwxrwxr-x  2 prayag prayag  4096 Nov 30 15:24 dist
drwxrwxr-x  3 prayag prayag  4096 Nov 30 15:24 doc
drwxrwxr-x  3 prayag prayag  4096 Nov 30 15:24 dsl-support
drwxrwxr-x  3 prayag prayag  4096 Nov 30 15:24 gradle
-rw-r--r--  1 prayag prayag     0 Feb 14  2012 gradle.properties
-rwxr-xr-x  1 prayag prayag  5060 Sep 12 10:27 gradlew
-rw-r--r--  1 prayag prayag  2404 Mar 29  2012 gradlew.bat
-rw-r--r--  1 prayag prayag   117 Feb 14  2012 INSTALL
drwxrwxr-x 64 prayag prayag  4096 Nov 30 15:24 lib
-rw-r--r--  1 prayag prayag 11564 Feb 14  2012 LICENSE
drwxrwxr-x  4 prayag prayag  4096 Nov 30 15:24 media
drwxrwxr-x  2 prayag prayag  4096 Nov 30 15:24 plugins
-rw-r--r--  1 prayag prayag  2890 Feb 14  2012 README
drwxrwxr-x  2 prayag prayag  4096 Nov 30 15:24 scripts
drwxrwxr-x  5 prayag prayag  4096 Nov 30 15:24 src


METHOD 2 : Installing through launchpad (skip this method if chosen METHOD 1)
This is alternative to method 1, so you can skip this if you went through METHOD 1.
This method itself has two ways,

prayag@prayag:~$ sudo add-apt-repository ppa:groovy-dev/grails
You are about to add the following PPA to your system:
 Grails is an advanced and innovative open source web application platform that delivers new levels of developer productivity by applying principles like Convention over Configuration. Grails helps development teams embrace agile methodologies, deliver quality applications in reduced amounts of time, and focus on what really matters: creating high quality, easy to use applications that delight users. Grails naturally complements Java application development since it is built on Spring and based on Groovy, the leading dynamic language for the Java platform.
 More info: https://launchpad.net/~groovy-dev/+archive/grails
Press [ENTER] to continue or ctrl-c to cancel adding it

gpg: keyring `/tmp/tmpDUEDzV/secring.gpg' created

gpg: keyring `/tmp/tmpDUEDzV/pubring.gpg' created
gpg: requesting key 02A9EC29 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmpDUEDzV/trustdb.gpg: trustdb created
gpg: key 02A9EC29: public key "Launchpad PPA for Groovy Developers" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK

OR add to /etc/apt/sources.list.d/groovy-dev-grails-precise.list
Don't execute this if you have already executed add-apt-repository.
   deb http://ppa.launchpad.net/groovy-dev/grails/ubuntu precise main
   deb-src http://ppa.launchpad.net/groovy-dev/grails/ubuntu precise main

Whatever you did above for METHOD2, execute following commands,
prayag@prayag:~$ sudo apt-get update
prayag@prayag:~$ sudo apt-get install grails-ppa
prayag@prayag:~$ sudo apt-get install grails 2.1.1

You are done with METHOD 2 !!!
Lets confirm where is grails installed,
prayag@prayag:~$ which grails
/usr/bin/grails

prayag@prayag:~$ ls -l /usr/bin/grails
lrwxrwxrwx 1 root root 24 Nov 21 00:56 /usr/bin/grails -> /etc/alternatives/grails

prayag@prayag:~$ ls -l /etc/alternatives/grails
lrwxrwxrwx 1 root root 34 Nov 21 00:56 /etc/alternatives/grails -> /usr/share/grails/2.1.1/bin/grails

prayag@prayag:~$ ls -l /usr/share/grails/2.1.1/
total 40
drwxr-xr-x  2 root root 4096 Nov 21 00:55 bin
-rw-r--r--  1 root root   22 Sep 12 15:12 build.properties
drwxr-xr-x  2 root root 4096 Nov 21 00:55 conf
drwxr-xr-x  2 root root 4096 Nov 21 00:55 dist
drwxr-xr-x  3 root root 4096 Nov 21 00:55 dsl-support
drwxr-xr-x 64 root root 4096 Nov 21 00:55 lib
drwxr-xr-x  4 root root 4096 Nov 21 00:55 media
drwxr-xr-x  2 root root 4096 Nov 21 00:55 plugins
drwxr-xr-x  2 root root 4096 Nov 21 00:55 scripts
drwxr-xr-x  5 root root 4096 Nov 21 00:55 src

METHOD 2 won't set any GRAILS_HOME variable which you may require later.


STEP 2 : Set the GRAILS_HOME environment variable to profile
prayag@prayag:/opt/grails211$ sudo vi /etc/profile
[...]
export GRAILS_HOME=/opt/grails/grails-2.1.1
#add the bin directory to PATH variable
export PATH="$PATH:$GRAILS_HOME/bin"


STEP 3 : grails bash autocomplete(optional)
STEP 3.1 : install gawk
$ sudo apt-get install gawk
STEP 3.2 : Download grails-autocomplete
STEP 3.3 : add to .bashrc     
[ -r /path/to/the/autocomplete/file ] && source /path/to/the/autocomplete/file

Part B : Creating an app
STEP 4 : create-app
Once grails installation part is done, it's great to great an app.
prayag@prayag:~$ grails --version
Grails version: 2.1.1

prayag@prayag:~$ mkdir -p workspace_grails/workspace_grails/
prayag@prayag:~$ cd workspace_grails/workspace_grails/
prayag@prayag:~/workspace_grails$ grails create-app gccount --stacktrace
| Created Grails Application at /home/prayag/workspace_grails/gccount

Structure of grails app 
prayag@prayag:~/workspace_grails$ cd gccount/

prayag@prayag:~/workspace_grails/gccount$ ls -l
total 28
-rw-rw-r--  1 prayag prayag  110 Nov  4 11:04 application.properties
drwxrwxr-x 10 prayag prayag 4096 Sep 12 10:30 grails-app
drwxrwxr-x  2 prayag prayag 4096 Nov  4 11:04 lib
drwxrwxr-x  2 prayag prayag 4096 Nov  4 11:04 scripts
drwxrwxr-x  4 prayag prayag 4096 Nov  4 11:04 src
drwxrwxr-x  4 prayag prayag 4096 Nov  4 11:04 test
drwxrwxr-x  7 prayag prayag 4096 Sep 12 10:30 web-app


prayag@prayag:~/workspace_grails/gccount$ ls -l grails-app/
total 32
drwxrwxr-x 4 prayag prayag 4096 Nov  4 11:04 conf
drwxrwxr-x 2 prayag prayag 4096 Nov  4 11:04 controllers
drwxrwxr-x 2 prayag prayag 4096 Nov  4 11:04 domain
drwxrwxr-x 2 prayag prayag 4096 Nov  4 11:04 i18n
drwxrwxr-x 2 prayag prayag 4096 Nov  4 11:04 services
drwxrwxr-x 2 prayag prayag 4096 Nov  4 11:04 taglib
drwxrwxr-x 2 prayag prayag 4096 Nov  4 11:04 utils
drwxrwxr-x 3 prayag prayag 4096 Sep 12 10:27 views

The structure of grails-app/conf/ is
prayag@prayag:~/workspace_grails/gccount$ ls -l grails-app/conf/
total 32
-rw-rw-r-- 1 prayag prayag   78 Feb 14  2012 ApplicationResources.groovy
-rw-rw-r-- 1 prayag prayag   88 Feb 14  2012 BootStrap.groovy
-rw-rw-r-- 1 prayag prayag 2017 Sep 12 10:27 BuildConfig.groovy
-rw-rw-r-- 1 prayag prayag 3852 May 14 17:43 Config.groovy
-rw-rw-r-- 1 prayag prayag 1225 May 14 17:43 DataSource.groovy
drwxrwxr-x 2 prayag prayag 4096 Nov  4 11:04 hibernate
drwxrwxr-x 2 prayag prayag 4096 Feb 14  2012 spring
-rw-rw-r-- 1 prayag prayag  180 Feb 14  2012 UrlMappings.groovy


STEP 5 : create-controller
prayag@prayag:~/workspace_grails/gccount$ grails
| Downloading: database-migration-1.1.zip
> ##########################################################.
Grails would like to send information to VMware domains to improve your experience. We include anonymous usage information as part of these downloads.

The Grails team gathers anonymous usage information to improve your Grails experience, not for marketing purposes. The information is used to discover which Grails plugins are most popular and is published on the plugin portal.


We also use this information to help guide our roadmap, prioritizing the features and Grails plugins most valued by the community and enabling us to optimize the compatibility of technologies frequently used together.


Please see the Grails User Agent Analysis (UAA) Terms of Use at http://www.springsource.org/uaa/terms_of_use for more information on what information is collected and how such information is used. There is also an FAQ at http://www.springsource.org/uaa/faq for your convenience.


To consent to the Terms of Use, please enter 'Y'. Enter 'N' to indicate your do not consent and anonymous data collection will remain disabled.

##########################################################.
Enter Y or N:[y,n] y                                
| Enter a script name to run. Use TAB for completion: 
grails> create-controller Main
| Compiling 113 source files
Note: /home/prayag/.grails/2.1.1/projects/gccount/plugins/cache-1.0.0/src/java/grails/plugin/cache/web/GenericResponseWrapper.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
| Created file grails-app/controllers/gccount/MainController.groovy
| Created file grails-app/views/main
| Created file test/unit/gccount/MainControllerTests.groovy


Change MainController.groovy
prayag@prayag:~/workspace_grails/gccount$ vi grails-app/controllers/gccount/MainController.groovy
package gccount

class MainController {


    def index() {"This is gccount!!!" }

}

"/"(

   controller:'main', 
   action:"/main"
)

STEP 6 : add mysql dependency to BuildConfig.groovy
prayag@prayag:~/workspace_grails/gccount$ vi grails-app/conf/BuildConfig.groovy

grails.servlet.version = "2.5" // Change depending on target container compliance (2.5 or 3.0)
grails.project.class.dir = "target/classes"
grails.project.test.class.dir = "target/test-classes"
grails.project.test.reports.dir = "target/test-reports"
grails.project.target.level = 1.6
grails.project.source.level = 1.6
//grails.project.war.file = "target/${appName}-${appVersion}.war"

grails.project.dependency.resolution = {

    // inherit Grails' default dependencies
    inherits("global") {
        // specify dependency exclusions here; for example, uncomment this to disable ehcache:
        // excludes 'ehcache'
    }
    log "error" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve

    repositories {

    [......]
    }
    
    dependencies {
        // specify dependencies here under either 'build', 'compile', 'runtime', 'test' or 'provided' scopes eg.

        runtime 'mysql:mysql-connector-java:5.1.20'

    }

    plugins {

     runtime ":hibernate:$grailsVersion"
     [...]
    }

STEP 7 : create database gccount at mysql server

STEP 8  : configure dataSource for mysql in development mode 
prayag@prayag:~/workspace_grails/gccount$ vi grails-app/conf/DataSource.groovy 
dataSource {
    pooled = true
    driverClassName = "org.h2.Driver"
    username = "sa"
    password = ""
}
hibernate {
    cache.use_second_level_cache = true
    cache.use_query_cache = false
    cache.region.factory_class = 'net.sf.ehcache.hibernate.EhCacheRegionFactory'
}
// environment specific settings
environments {
    development {
        dataSource {
            dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
            driverClassName = "com.mysql.jdbc.Driver"
            url = "jdbc:mysql://10.13.212.4:3306/gccount"
            username = "root"
            password = "mysql55"
        }
    }
    test {
        dataSource {
            dbCreate = "update"
            url = "jdbc:h2:mem:testDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
        }
    }
production {
        dataSource {
            dbCreate = "update"
            url = "jdbc:h2:prodDb;MVCC=TRUE;LOCK_TIMEOUT=10000"
            pooled = true
            properties {
               maxActive = -1
               minEvictableIdleTimeMillis=1800000
               timeBetweenEvictionRunsMillis=1800000
               numTestsPerEvictionRun=3
               testOnBorrow=true
               testWhileIdle=true
               testOnReturn=true
               validationQuery="SELECT 1"
            }
        }
    }
} 

STEP 9 : create domain-class
 prayag@prayag:~/workspace_grails/gccount$ grails create-domain-class User
| Created file grails-app/domain/gccount/User.groovy
| Created file test/unit/gccount/UserTests.groovy

Change domain User.groovy
prayag@prayag:~/workspace_grails/gccount$ vi grails-app/domain/gccount/User.groovy
class User {
    String name;
    String password;
    Boolean active;
    static constraints = {
    }
}


prayag@prayag:~/workspace_grails/gccount$ grails generate-all gccount.User
| Finished generation for domain class gccount.User

Check grails-app/views/user directory
prayag@prayag:~/workspace_grails/gccount$ ls -l grails-app/views/user/
total 20
-rw-rw-r-- 1 prayag prayag 1590 Nov  4 13:30 create.gsp
-rw-rw-r-- 1 prayag prayag 2093 Nov  4 13:30 edit.gsp
-rw-rw-r-- 1 prayag prayag  787 Nov  4 13:30 _form.gsp
-rw-rw-r-- 1 prayag prayag 1926 Nov  4 13:30 list.gsp
-rw-rw-r-- 1 prayag prayag 2704 Nov  4 13:30 show.gsp

Check grails-app/views/controllers/gccount directory
prayag@prayag:~/workspace_grails/gccount$ ls -l grails-app/controllers/gccount/
total 8
-rw-rw-r-- 1 prayag prayag   83 Nov  4 11:46 MainController.groovy
-rw-rw-r-- 1 prayag prayag 3489 Nov  4 13:30 UserController.groovy

STEP 11 : Check routing file UrlMappings.groovy

Check UrlMappings.groovy
class UrlMappings {

        static mappings = {

                "/$controller/$action?/$id?"{
                        constraints {
                                // apply constraints here
                        }
                }

                "/"(view:"/index")

                "500"(view:'/error')
        }
}



STEP 12 : change grails-app/views/index.gsp
prayag@prayag:~/workspace_grails/gccount$ sudo vi grails-app/views/index.gsp

<div id="page-body" role="main">

                        <h1>gccount</h1>
                        <p>Welcome to gccount ! Your money friend anytime, anywhere.</p>

                        <div id="controller-list" role="navigation">

                                <h2>Available Controllers:</h2>
                                <ul>
                                        <g:each var="c" in="${grailsApplication.controllerClasses.sort { it.fullName } }">
                                                <li class="controller"><g:link controller="${c.logicalPropertyName}">${c.fullName}</g:link></li>
                                        </g:each>
                                </ul>
                        </div>
</div>


STEP 13 run app
prayag@prayag:~/workspace_grails/gccount$ grails run-app

Goto browser, and hit http://localhost:8080/gccount/ or http://localhost:8080/gccount/user/list



References
Getting Started - Reference Documentation, available at
http://grails.org/doc/latest/guide/gettingStarted.html#downloadingAndInstalling



Part C : Using git
Make sure you have git installed. You know git is a source control tool.

STEP C1 : initialize git
prayag@prayag:~/workspace_grails/gccount$ git init
Initialized empty Git repository in /home/prayag/workspace_grails/gccount/.git/

STEP C2 : check git status
prayag@prayag:~/workspace_grails/gccount$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       .classpath
#       .project
#       .settings/
#       application.properties
#       grails-app/
#       target/
#       test/
#       web-app/
nothing added to commit but untracked files present (use "git add" to track)


STEP C3 : ignore some files
prayag@prayag:~/workspace_grails/gccount$ touch .gitignore
prayag@prayag:~/workspace_grails/gccount$ vi .gitignore
*.iws
*Db.properties
*Db.script
.settings
eclipse
stacktrace.log
target
/plugins
/web-app/plugins
/web-app/WEB-INF/classes

STEP C4 : create an initial commit
prayag@prayag:~/workspace_grails/gccount$ git add .

prayag@prayag:~/workspace_grails/gccount$ git commit -m "[creating initial framework for gccount]"

[master (root-commit) 89fac4c] [creating initial framework for gccount]                                                                                                                  
 112 files changed, 5178 insertions(+)  

STEP C5 : create repo at github

STEP C6 : create a remote named "origin" pointing at github repo
prayag@prayag:~/workspace_grails/gccount$ git remote add origin https://github.com/iPrayag/gccount.git

Send commits in the "master" branch to GitHub
prayag@prayag:~/workspace_grails/gccount$ git push origin master
Username for 'https://github.com': iPrayag
Password for 'https://iPrayag@github.com': 
To https://github.com/iPrayag/gccount.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/iPrayag/gccount.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.  See the
'Note about fast-forwards' section of 'git push --help' for details.

#The error is because i created .gitignore on both side, no matter I want to force update
prayag@prayag:~/workspace_grails/gccount$ git push origin master --force
Username for 'https://github.com': iPrayag
Password for 'https://iPrayag@github.com': 
To https://github.com/iPrayag/gccount.git
 + f46deda...89fac4c master -> master (forced update)

STEP C7 : Check remote origin

prayag@prayag:~/workspace_grails/gccount$ git remote -v
origin  https://github.com/iPrayag/gccount.git (fetch)
origin  https://github.com/iPrayag/gccount.git (push)


Source Code
available at https://github.com/iPrayag/gccount