If you code for yourself or with a team you should be using a code repository. However getting started you need a dedicated server, installation etc. or you take the more convenient route and use one of the many repository providers.
Step 1: Get a Repository
For small teams, you can get free Repositories. The two most popular providers are:
- Github.com: Allows you to host as many open source projects as you like. (private projects cost a monthly fee)
- Bitbucket.com: Allows a small team to host private projects. (As the team gets bigger you got to pay a monthly fee)
Larger teams, hopefully, have the budget to pay for these awesome services.
Step 2: Set up your SSH key
Eclipse and Aptana Studio have Git already integrated. Git uses an encrypted connection to transmit data. You need to provide a SSH keypair.
Check for existing SSH keys
- Go to the directory “C:\Users\\.ssh”
- Check if the files “id_rsa” and **”id_rsa.pub”**exist
Generate new SSH keys
If the two files already exist, you can skip this step.
- Open git-bash.bat (either by using windows search or navigate to C:\Users\%USRNAME%\Documents\Aptana Studio 3 Workspace\.metadata\.plugins\com.aptana.portablegit.win32\git-bash.bat)
- Enter the following command using your correct email-address.
ssh-keygen -t rsa -C "firstname.lastname@example.org"
For the first question, just press enter. [bash] Generating public/private rsa key pair. # Enter file in which to save the key (/c/Users/you/.ssh/id_rsa): [/bash]Now enter a passphrase for your key (Password Generator) and confirm the password
Add SSH key to Repository
- Go to the directory “C:\Users\\.ssh”
- Open the file ‘id_rsa.pub’ in a text editor
- Copy the entire contents to the Clipboard (Ctrl-C)
- Open a web browser and log in to github.com or bitbucket.com
- (Github) Click on the “Edit my profile” button on the top right
- (Bitbucket) Click on your Avatar > “Manage Account”
- On the left side navigate to “SSH Keys”
- Click “Add SSH key”
- Give the key a title (like username with the computer name) and paste the key into the form
If everything went well you will get a message like: Hi, username! You’ve successfully authenticated, but GitHub does not provide shell access. Note: At first I had difficulties to establish a connection. If you are having problems, check if the keys are in the right directory and have the proper names id_rsa and id_rsa.pub. Source/Further information: Github – https://help.github.com/articles/generating-ssh-keys
Step 3: Set up Aptana/Eclipse
The initial setup is now complete you can now use Eclipse/Aptana to access your Repository.
To start using git create or use an existing project.
You now have a local git repository. You now can “Push” the repository to github/bitbucket.
First, create a Repository on the website and copy the address of the repository
Give the remote a name and paste the address of the repository
Finally, push your initial commit with Team > Push
Retrieve from Repository
If you already have a Project stored in your repository and want to retrieve it.
Go to **File > Import **
Enter the URI of your repository:
Use your Repository
Here are some tips on using the repository (well they are based on my experience using SVN, but the same principles apply):
Commit as often as possible
The beauty of subversioning is that you can figure out step by step what parts of your code created the error. When working in a team, always make sure that the entire code is correct and valid and still be compiled/executed.
Write proper commit messages
Always comment what you are currently committing. It helps to rollback to a specific point, and it is a documentation of your work.
When working in a team regularly check that you have the newest version of the code available by doing a “Pull”.
A lot of experts have articles on how to use git effectively in a team. Read up on them and see if they are suitable for your team. Check out this article about Git Best practices.