One of the most interesting thing to do for a programmer whether he is student or professional is to team up with other guys in school/college/work and create a project. That’s the real fun.
Now you gathered a team, where’s the venue? That’s where Git comes. It provides a fully featured code sharing environment making our life way more easier.
While knowing Git commands might be helpful… there is no necessity.
Make way for GitHub
So without knowing the commands, how can we manage them? Say hi, to our guy : GitHub
GitHub provides all the frontened to manage the operations in Git. Now, I am not going to dive deep into GitHub, for the sake of keeping this instructive simple. Just create a account there and we are good to go. Don’t forget to verify your email address.
Goto Control Panel->System->Advanced System Settings->Environment Variales
- In the User variables section, if there is already a HOME variable…just leave him alone and skip these 3 steps
- or else click “New“
- Enter Variable name: HOME
- And Variable value: <path to your Home folder>. (e.g) C:/Users/Home –> where Home is the name of your User Account.
Next thing you have to do is to install Eclipse. If you already have one, make sure you have the latest version installed.
Here comes the hard part (not really…)
Open Eclipse, create a project or open existing project which you want share.
Goto Window->Prefernces->General->Network Connecion->SSH2->Key Management
- Click “Generate DSA Key…“. The text area below this button gets crowded
- Copy that key for now.
- And finally click “Save Private Key…“. Save anywhere you want and click “OK“
Git has two reposotories, one is the local repository(you have it with you) and the other is the remote repository. And they are not automatically synchronized. So, we have our local copy here, lets update it to the servers.
To make our local project a local repository,
Select the project you want to share, right-click->Team->Share Project
- Select Git and click “Next“
- Create Repository if you have none or you ccan select from the existing repositories and click “Finish“
Now, you can see your project gets associated with EGit. But you will see “[NO HEAD]” kind of description.
To resolve this, goto right-click the project->Team->Commit…
- First time you’ll make a commit, it will ask for a username and e-mail(GitHub credentials obviously), enter them and click “OK“
- Enter any text in commit message
- select the files you want upload
- and finally click “Commit and Upload“
To view the repositories,
Goto Window->Show View->Other->Git->Git Repositories
In the Git Repositories menu,
- Select the Remote Folder ->right-click->Creaet Remote
- Enter Remote name something like “origin” and click “OK“
- This will get you into GitHub settings page(in Eclipse).
- Now goto your GitHub account Settings(in Webpage)->SSH and GPG keys->New SSH Key
- Enter the Title(any name actually…) and the Key from which we acquired from Ecllipse(the one I told you to copy before)
- Save the key and copy your page URL(which is the URL shown when you sign in)
- Press the “Change” option in GitHub settings page(in Eclipse).
- Enter the URL you copied and change protocol to “ssh”
- Click “Finish“, It’ll ask you to set a password(I leave this option to you)
- Finally, click “Save and Push“
Open Eclipse, right click the project you want to commit(a fancy name for upload) and then select Team->Commit… or use the shortcut Ctrl + #
The changes you have made should be entered in Commit message which shows others the changes you have done.
Click “Commit and Option” to upload the files and sync the local repository with server or click “Commit” to inform others that you’re working on the selected files.
That’s all there is to it… Happy Coding!