[Android] Calin:
SmartGit

Intro and Installation

​

In order to commit the changes that you are going to do on the different Repositories i recommend you to use SmrtGit which is a free tool and it will help very much in the work that we will gonna do.

1) First of all if you didn't downloaded the link is situated in the first post

2) Once you downloaded unpack the tar package and unpacked it to your Desktop or /home

3) Now open the folder and go to the bin one.

Now go to the smartgit file proprieties and check if the file is executable, if it's not check the check box and open it.

g

4) Once you opneed a window will be prompted to configure SmartGit, choose the non-commercial use only and click next

5) Now choose to use SmartGit as SSH Client

6) Configure a new hosting provider which it will be Github in our case.

Insert your e-mail and after click the Generate API token button

7) Insert your master password which it will be useed for the commits

8) Insert your Github password

9) Now the that the token is generated click next

10) Now SmartGit will search if you got already repositories in your home folder, if you want to include some of yours go ahead.

11) Now next and finish. Hurray! You finished to configure SmartGit

How to use SmartGit

​

Now in order to apply the incoming commits that we will gonna do, first you need to understand some concepts:

In the early post about Repo we were talked about the fact that we could have 2 kind of repositories, the forked ones and the created ones in that organization.

If you want to add a forked repo from SmartGit you will have an origin branch which is yours then it comes the upstream one.

Upstream is corresponding to the original repo that includes the branches from the Original forked repo. So when you want to add a new forked repo from your organization to Smart Git make sure that you clone it with SmartGit in order to include also the upstream tracking one because we will work and commit our changes but in the main time maybe CM will also push new commits so these commits should also be included in your forked repo.

If you want to add a created repo from your organization instead, and you also want to include the upstream changes from the native repo from where you taking the code then you will need to add the upstream for your own. So just follow my commands:

For example i will be taking Settings (The package) and i will add the upstream in order to have in my local repo also the original sources (In my case from crDroid):

Just adapt the link to your repo one.

The upstream should now be visible as it here and also in SmartGit.

It's not mandatory to include every single commit that for example Cyanogenmod make but most of them should absolutely be included. Yup,so upstream it's very important guys but it will also create difficult situations because now we will talking about the conflicts problem.

But what are exactly the conflicts?

The conflicts are generated when you want to include upstream commits to your own Repo no matter if it's created or forked, so the thing to do is only to adapt them and here once again SmartGit will save our "lives"

Why it will save our lives ?

Because SmartGit includes an inbuilt file compare which is very useful when resolving conflicts.

So to show you let's take in consideration still Settings. In my case the repo is not forked but it's created and the upstream is created for myself. So let's include some commits and see how it goes. In the major part of the cases you will not get conflicts errors. But if you do get then follow up this procedure:

As we know here is the Origin remote which is mine an the upstream remote which is crDroid one:

So what you need to do in order to include a commit made in the upstream one?

Well there are a few methods to do it.:

There is the cherry-pick method and usually is the most used to pick up two or three commits.

The merge method which allows you to merge all the missing commits from a based branch into your current one. (Here the possibility to find out conflicts are bigger)

The rebase method, which basically rebase your current branch to a specified one.

In my case i will use the merge method, and i will sync up my remote with the original crDroid one by including the missing commits.

For me everything went good, so i'm just gonna push now the new changes

Now if something go bad which means you end up with conflicts here is how you need to solve them.

Basically conflicts are appearing most of the cases because you for example modified a file and the commit which you want to apply go modifying the same file but for the fact that the file is not the same as the upstream on conflicts appear, so you need to find out a solution in order to keep your changes made to that file but in the same way including the specific commit.

When you will rebase, cherry-pick or merge the conflicted files will be the first ones to appear so to solve them here is what you need to do:

Double click the conflicted file

Now a new window will be displayed:

You will see that the file compare will be split in three parts, i mean three columns.

So let me explain you what are the three columns:

By starting from the left the first one indicates our branch the origin one.

The second one represent the Working Tree *

The third one represent the upstream branch from where we are cherry-picking or merging the commit

Working three*

The working three basically represents a detached branch,where you are working.

On local the branch is still the same (name etc..) but is being considered in a different way till you push up the changes.

If you will get familiar with this then you will not have problems with other minor issues.

So this is it, if you got questions or errors just write them on the Thread ;)