GitHub into Eclipse

Assumes Git is installed and configured on the computer already.

I used the link below to learn how to use GitHub clone

https://help.github.com/articles/fork-a-repo

1) First, Fork the repository you’re interested in.  This will make a copy in your own GitHub directory.  Do this by clicking the “Fork” button in the top-right corner of the page you want to fork.

2) Open Git Shell.  Navigate to the location you want the project to reside.  Since I’m pulling down a PHP project I’m going to navigate to “htdocs” directory inside XAMPP.  I don’t need to make a new directory because the git clone will create a directory wtih the name of the project.

3) Clone the project into your local area by typing what’s in the box labeled “Git Read-Only”

git clone git://github.com/idiosyncraticee/android-market-api-php.git

4) Change to the directory you just pulled

cd android-market-api-php

5) Link to upstream project that you forked from.  Just change out “https” for “git” and the username you forked from for your username.  In the example below the person I forked from is named splitfeed.

git remote add upstream https://github.com/splitfeed/android-market-api-php.git

Whenever you want to update from the upstream do

git fetch upstream

6) In Eclipse go File->Import->Git->Projects from Git

Select Local and click Next

Click Add and browse to the location of the repository you just cloned.  If there is a proper git repository there you should see a yellow cylinder with a checkbox next to it.

Click Finish, Next

When it asks, choose Use the New Project wizard and click Finish

This will open up a New Project window

For my project I’ll select PHP and I’ll select Create project at existing location (from existing sources) and I’ll point at the same location as the git clone.  For the “Project name:” I just use the same name supplied in github.

FInally click Finish

7) Ignore a file

I want to create a file that contains secret keys for use in my local repository, but obviously I don’t want to publish these to GitHub.  The way I handle this is with a .gitignore file.  In order to create this just go New->File and call it .gitignore

In the .gitignore file put the name of the file to ignore.

Things that go wrong

1) Forgetting to do git init

If you forget to do git init (step 4)), you will be able to perform step 3), but on step 5) you’ll get the error message “fatal: Not a git repository (or any of the parent directories): .git

Speak Your Mind

*

DSCF0006