What is the best way to use GIT for versioning Java Website

I have a git repo installed in my unix for version tracking our Java EE website.

I have currently run into issues not in the usage of git but the way in which I am suppose to use it which is explained below.

  • Gitlab Push Failed error
  • Git log for range across all branches (even remote)
  • Merge branch 'master'
  • How much overhead time and learning time to use version control?
  • git clone fatal error : RPC failed , The remote end hung up unexpectedly, early EOF
  • Git does not recognize repositories while executing a hook
  • I work in a team of 3 developers which contribute to the website development.

    Initially when I installed Git in our server I directly created a repo of our webapps directory which contains the actual work files and ran into the foll problems.

    1)While committing the changes into the repo one of us would genrally do a git add . and commit it to the repository which would commit not only the files the commiter changed but would also commit the changes of other developers.

    When we faced this issue we decided that we needed to create separate non-bare repos for each one of us in the same server in different directories which would house the entire code.The basic work stucture we are following is hown below:

    enter image description here

    As shown above in the image we have created a bare repo which would have the website contents pushed by the webapps which in the image is the Work Directory.

    The basic workflow here is:

    1) Create n number of non-bare repos for each and every developer.

    2) Get the entire website work files from pulling from that bare repo

    3) After making changes to our own repo push to the bare repo

    4) The bare repo being configured with a post-receive hook would actually update the Work Directory.

    This setup is working fine but we are facing a lot of issues as shown below:

    1) Each developer having his own contetnts in a separate directory is not able to test the code before pushing it to the bare repo which would update the Work Directory- Coz of these steps even for say one jsp file change I end up doing 20 commits until it starts working properly without bugs since we have tomcat pointing to only the original work directory.

    This has become the most troubleseme issue here.

    This strategy has solved the issue of conflicts which was there before but created even a greater issue regarding testing the code.

    How can we improve this scenario where using GIT in out project seems benefitial.

    Can anyone suggest any ways for improving the same.

  • Git push to DigitalOcean from Bitbucket or Cloud9
  • Stop git from silently clobbering ignorefiles (bug in git?)?
  • Is there a tool that automatically saves incremental changes to files while coding?
  • “HEAD not found below refs/heads” after I push commit with CR/CRLF changes
  • How to make pull request to Visual Studio Online
  • Can I automate an application deployment via webhook to OpsWorks?
  • One Solution collect form web for “What is the best way to use GIT for versioning Java Website”

    Maybe a strategy like this might work? I’ve used a similar strategy before with a small team and it worked well for us:

    • Each developer creates a branch before making any changes.
    • Developer does some work and commits to their branch
    • If possible, developers run tomcat (or jetty, or whatever) against their own directory to test. Maven makes this really easy.
    • Before pushing, developers rebase their branches against master
    • Developers push their branch to bare repo
    • Then you (or whoever is in charge of final approval), merges the branch into master. If the developers rebase correctly, this should be a simple fast forward merge.

    Updated with some ideas about how each developer might run webapp:

    There are a few ways I can think of to accomplish the 3rd bullet point above:

    • Use a single installation of tomcat. Create multiple contexts, one for each developer.

      For example, for developer1, create a context file named dev1.xml under tomcat_home/conf/catalina/localhost with something similar to:

      ?xml version=”1.0″ encoding=”UTF-8″?>
      Context path=”/dev1″ docBase=”/home/developer1/wars/your-webapp-1.0.war” unpackWAR=”false”/>

      (note I removed the first ‘<‘ so xml will appear in the post)

    • Use jetty to run the war using command line, something like:

      java -jar jetty-runner.jar your-webapp-1.0.war

    • Use mechanisms provided by a build tool like ant, or maven to run and test the webapp. For example, in maven you can use the jetty-plugin to run the webapp using mvn jetty:run, or even configure it to start a webserver and run tests each time you build the project.

    Git Baby is a git and github fan, let's start git clone.