Saturday, June 22, 2013

GitHub - Source Code Control

Why GitHub ? 

Github is basically a version control system same as SVN (SubVersion) or CVS to maintain your code in the web UI. Very popular openSource component to keep our code. It has 2 feature Public or Private. Public projects will be viewed by anyone. You will find most of the openSource code published in GitHub. You can integrate gitHub easily with standard editors "Eclipse, Netbeans, IntelliJ.."

Latest Eclipse (Luno) release comes with GitHub plugin as in-build. You can checkout your source and check-in easily.

GitHub in Command Line In Interface on Ubuntu
Install Git in Ubuntu
$ sudo apt-get install git
How to Checkout from Git?
$ git clone https://github.com//.git

How to Check status on your directory with git master ?
$ cd ~/
$ git status -u origin master
Pull your changes from GitHub
$ cd ~/
$ git pull -u origin master
Push your changes into GitHub
$ git add 
$ git commit -m "Adding  into Git"
$ git push -u origin master
Add your existing project into Git
Login to your gitHub in web UI
Create a Repository in your github UI 

Push project from Terminal into your created Git Repository
$ cd ~/
$ git init
$ git add 
$ git commit -m "Adding projects into git" .
$ git remote add origin https://github.com/username/projectName.git
$ git pull -u origin master 
$ git push -u origin master

Check out GitHub project repository into Eclipse
  • Open Eclipse with workspace
  • Go to Window > Open Perspective > Other > Git > Ok
  • Right click and select 'Paste Respository Path or URI'
  • Copy and paste the Git URI from Git Web UI > HTTPS Clone URL
  • Move on with Next and finish to checkout repository into your workspace
  • Select Git Repository > Right Click 'Import Project' > Select your project into working directory > Finish
Convert Regular checkout project into Java Project in Eclipse
  • Select your project > right click > Properties > Project Facets > Click 'Convert to faceted form..'
  • Select 'Java' and 'Version' change in dropdown if you have multiple version
  • Click 'Apply' > Ok
Create sourceFolder (src/main/java) for your project in Eclipse
  • Select your project > right Click > Source Folder > FolderName 'src/main/java' > Finish 
  • Select your project > right Click > Source Folder > FolderName 'src/main/test' > Finish 
Push your changes into Git Repository through Eclipse
  • Open Eclipse with Workspace had checkout project from git. 
  • Select your project > right Click > Team > Add To Index (Need to add first)
  • Select your project > right Click > Team > Commit > provide commit message > commit and push > ok
Pull your changes into workspace from Git Repository through Eclipse 
  • Open Eclipse with Workspace had checkout project from git.  
  • Select your project > right Click > Team > Pull
Note : You can do synchronize with Repository through Team > Synchronize Workspace to sync and verify the pull or push changes before you do.
Try : Familiar yourself with Git in 5 mins

No comments :

// Below script tag for SyntaxHighLighter