Skip to main content

Using git hub with eclipse (EGit)

UPDATE: the first section talks about dealing with existing local repo
I added a new section to clone a repo from the scratch by EGit without using any external tool like Git Bash

Section 1 : Working with existing Repo

Today I'm going to try EGit to integrate a local and remote repository with eclipse

let's start by running eclipse > File > Import :





Then I added a Class called Tester to this project and committed it through git bash ( to test if eclipse will sync if I use git bash)




 Until then the project didn't look like it was connected with my local repository, I right-clicked the project in eclipse > Team > share project :



After I clicked finish the source control icons in eclipse appeared :


so eclipse connected well to the local repository without loosing any info as you can see '' is appearing as committed.

Now we will start using EGit, and to do that I added another class 'Tester2' and committed it:


Now the file is committed, let's try to push it to the remote repository:
right click the project > Team > push branch 




Done! very smooth process with good GUI from eclipse to do basic functionality like adding files and committing then push to remote, lets try more features.

1- branching

create new branch 'dev-adding-feature1':

add new Interface :, at first the file won't be tracked by git, to add it to the tracking tree right click the file > Team > Add to Index :

This file will now appear like this in the commit screen:


 but we also want to remove the configuration files from appearing here since they are not to be committed, let's add them to the ignore list:
switch to navigator view (  window -> open view -> navigator )
Now the commit screen is clean :


Now let's commit and push to the remote repo:





this will create a new remote branch on git-hub

let's do a pull request and merge dev with dev-adding-feature1


Now dev has feature1 folder and interface:


Now let's switch locally to the dev branch instead of dev-adding-feature1 to update our local dev branch with the new changes:

before update (no feature 1)

go to Team > Remote > Fetch From ..





Now the HEAD changes are fetched for all repositories, we will need to merge the remote dev branch with our local dev branch to see the changes: 

go to Team > Merge..

from local section, dev branch will be selected, and from Remote section, select origin/dev
Now the new commits (changes) will be available in our local dev branch.

another way to do this is to do a Pull. it will automatically do a fetch then merge.

if a conflict happens we will need to resolve it before merge is possible.

Section 2 : only using EGit to clone the repo:

to clone a repo go to File > Import , Select Git

Select Clone URI, then copy the https url and put in your git hub user name and password:

after that the info of the repository will be fetched

Click next and choose the branch that you want to work in, for now I selected master.
after that you will be promted to select a project, in my master I didn't had any so I had to finish the wizard there.

Now because I didn't select the proper branch [ has no projects ] to switch branches in EGit go to to:

Window > Show view > Others : Git > Git Repositories

right click the repo name and you can switch branches :

then create a new local branch and check it out then import the project as in section 1.


Popular posts from this blog

Android RecyclerView - Adding Empty View

So RecyclerView was introduced to replace List view and it's optimized to reuse existing views and so it's faster and more efficient as stated in the documentation:

While using it, I faced the issue of missing a useful functionality that is implemented in ListView.
that feature is setting an empty view in case there was no records.

In ListView it was as simple as this

View emptyView = findViewById(;
ListView  myList = ....

but this method doesn't exist for recycler view so we need a work around until android team fixes this.

and here are the screen shots of both list view and recycler view fix

List view :

Recycler view :

here is how I fixed it:

here is the content of empty_view, it can be anything.


Android - Multiple themes for one application

Sometimes you want to have multiple themes for your app
one strong example is having the ability to switch between dark and light themes because during night, a white bright screen can really be annoying for users eyes

Android will do most of the work for you but it may be required to change icons between themes to fit colors
In this blog I'll show a simple app with both dark and light themes and how to change icons without having to do that from code and keep things clean and centralized.
first of all let's create our activity, it will look something like this :

In /rest/values/styles.xml, we inherit Theme.AppCompat
        Base application theme, dependent on API level. This theme is replaced
        by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
    <style name="AppBaseTheme" parent="Theme.AppCompat">
            Theme customizations available in newer API levels can go in

Creating your own OAuth2 server and clients using spring security - part 1

In this series of posts, I'll try to put together a simple working example on how to create your own OAuth2 server.

if you want to know more on OAuth2 and when to use it as authentication and authorization protocol then you can search about it on google and i'll put some URLs later.

Now I assume you are familiar with java web applications using Spring and maven.

to get started we need to create the server side with all dependencies required and i'll list them here, i'll use maven 2 to ease downloading dependencies for us.


1- Create new maven project with arch type webapp:

2- Add the required depenedencies for spring, spring security, spring-oauth2, hibernate & other libraries (required for this tutorial only you can use other libraries if you like)

3- I used hibernate to automate the creation of the schema required by spring OAuth2 to manage tokens (it's required to have schema created in db if you a…