Showing posts with label Git. Show all posts
Showing posts with label Git. Show all posts

Thursday, 12 June 2014

Java EE Web App (part #4)

Configuring SVN Server


Setting up SVN Server is a big pain in a** specially if you are behind router because router does the NATTING for you (private IP to Public IP & Vice-Versa) and you need to forward request from public IP to appropriate private IP because in my place there are 5 private IP's.

Today i will simplify this a bit just follow the steps as shown below...

Steps 
  1. Download VisualSVN
  2. Installation is simple just follow the on-screen instructions
  3. Once you installed first step is to open your router page
  4. Goto Status tab and look for IP address, Once found copy it, now come to VisualSVN application, and select VisualSVN Server (Local) right click goto Network tab and under "Server Name" paste that IP
  5. Set "Server Port" to 8443 and press "Ok" button
  6. Then select Users --> right click --> Create User.. a dialog box will pop-up enter username & password which you wanna set and press "Ok" button
  7. Then select Repository --> right click --> Create New Repository, give a name and press "next" button
  8. Then select empty repository and press "Next" button
  9. Then select permission as per your convenience, i selected the default option which was already selected, Then select "Create" Button
  10. Now goto "C:\Repositories" you will find the repository which you just created, browse that directory 
  11. And from that directory which will be empty, perform right click and select TortiseSVN --> Create Repository Here..(follow the same step we have done in http://inaved-momin.blogspot.in/2014/06/java-ee-web-app-part-3.html)
  12. Then again right click and select SVN Checkout and in the "URL of the Repository" field enter the path where you have saved your "foobar" project. for eg: under NetbeansProjects in Documents
  13. Then "Checkout directory" field will contain path to this directory where you are standing for eg: "C:\Repositories\foobar" where "foobar" is the name of the repository which i have created in step 7
  14. Press "Ok" button
  15. Now goto that VisualSVN application and see whether new files have been added to your repository or not, try to browse it using for that select the repository and right click --> Browse
  16. If it opens in browser and you can see files means it is working else perform step 17
  17. Again goto router page, and goto "Advanced" tab which says "Advanced Port Forwarding Rules" in that perform as I say in step 18
  18. Name should be "VisualSVN", Application Name "HTTPS", Public port should be 8443,IP Address is the private IP address (as it starts with 192.168.*.*) see figure 1.0 more for more clarity
  19. Then Save Settings, It will ask for reboot, so reboot it and then try to browse the repository from VisualSVN it will work now
Note: Important point is once you shutdown your router and restart there is a probability that your private IP might change from 192.168.0.100 to 192.168.0.102 or vice-versa depending on the machines in your private network, in that case you need to perform step 18 & 19 again and again each time your private IP changes to map Public IP to appropriate private IP.

Changes should take place only in second row first row should be 
intact, in 2nd row only select the machine name and click that button next to it "<<" button and save settings.


 
Image 1.0

For more clarity this post should be read alongside with this post.

Now you have working SVN Client & Server, enjoy collaborative coding .....:)))


Java EE Web App (part #3)

Versioning Tool #2 (SVN)

Since the complexity needed to understand and operate Git is too high we here try to understand SVN which serves similar purpose as Git. It is used by many heavy weight Tech Companies across the globe.

Assuming there is a VisualSVN server running at developer "x" side which contains the latest up-to-date copy of our project "foobar"

steps needed to copy the latest "foobar" project from developer "x" machine to your machine.

Steps
  1. Download & Install TortiseSVN
  2. Create an empty directory on your desktop named "mynewproj"
  3. Browse in that directory mynewproj and do right click and select TortiseSVN --> Create repository here
  4. It will prompt a dialog box in that dialog box click on "create folder structure" button and then "ok" button
  5. Then again right click and select SVNCheckout, which will bring a dialog box in front of you
  6. In the field named "URL Of The Repository" enter URL which you get from developer "x" which has VisualSVN Server up and running, who also has the fully up-to-date project "foobar" (eg. URL will be like https://IP:port/svn/projectname) after you enter "ok" button a dialog box will pop-up which will ask for username and password, make sure you have one
  7. Then in the "Checkout" text-field select the directory "mynewproj"
  8. Then click on "ok" button, It will bring the latest copy of project "foobar" on your machine
  9. Open Netbeans 8.0, open project from the directory "mynewproj" (in our case it was "foobar")
  10. Perform some modifications ...blah blah...
  11. Now come back again to directory "mynewproj" select the project "foobar" do right click and select "SVN Commit...." it will again ask for username and password, make sure your developer "x" has provided you the same
  12. Once it is done, developer "x" on his machine will have to select the project "foobar" from Netbeans and perform step shown in step 13
  13. Right click on "foobar" project from Netbeans and select Subversion --> Update --> Update with Dependencies
viola !! you have just learned 50% of SVN....congo !!!

For learning how to setup and configure the SVN Server wait for Java EE Web App (part #4)

Java EE Web App (part #2)

Using Versioning Tool In Netbeans 8.0(Versioning Tool #1)

steps


  1. Dowload Git Version Control Tool.
  2. Follow the below screen shot for installing Git.





So, now we have installed Git, now time to use it in our web app created in part #1 of this series.

steps

Start git bash, a command line console will pop-up.

  1. Then navigate to location where you have stored your "MyFirstWebApp" created in part #1 of the tutorial series. (for eg: "C:\Users\Admin\Documents\NetBeansProjects\MyFirstWebApp")
  2. Enter the following lines in git bash
  3. git init
  4. git commit
  5. git add .
  6. Then start Netbeans 8.0 and select Team-->Git-->Connect (if it is not already connected)
  7. If it gets connected you will see image 1.0
  8. If it is not connected you will see image like 1.1
  9. Now if you see image like 1.0 select "MyFirstWebApp" 
  10. Right click and say git-->commit
  11. Enter some message and click on commit button
  12. Now to see if it is working or not ?
  13. Goto index.html file and after a line in body tag keep pressing enter key for 3-4 times you will screen a green color appearing in your IDE as shown in image 1.2
    Image 1.0
     
     Image 1.1

    Image 1.2
Purpose Of Using Git

  1. Suppose there is 3 people (x,y & z) together working on a project called "foobar".
  2. Project "foobar" has a central repository with developer x (or hosted on GitHub.com)
  3. Developer y & z does "Git clone" once to create a local copy of project "foobar"
  4. Developer y & z everyday in morning (or whenever they start developing work) do "git pull" to get all the latest update of the project "foobar" from central repository, Now they will start working on the latest copy of the project
  5. At night (or when they finish developing work) all 3 i.e x, y & z performs "git push" to make changes on the central repository saved at workstation of developer x (or at GitHub.com).

Some usefull commands

  1. Git clone URL:
  2. After you have done a git clone, you have a copy of the complete repository.
  3. Make some changes to the local version of the repository, then git add and git commit the changes to the local repository.
  4. Git push to publish the changes (“commits”) to the remote repository
  5. Periodically git pull to retrieve any new updates from the remote repository.