How to use Git on Android?

AndroidGitSynchronization

Android Problem Overview


I have a desktop application using git for synchronization. I have also an android application which do the same as the desktop, but I don't know how to do the synchronization part on it. I haven't found any implementation of git on android. I found a jgit, but its unwell documented and I was not able to do even a commit with that.

I was thinking about remote commands to my git server from my android app, but this is really a tease for me. Could you tell me if any other git implementation which can be used on android exists? If you have any idea how to solve that, please tell me.

Android Solutions


Solution 1 - Android

Since this question was first posted, an Android app has been added to the market that can checkout Git repos, called Agit. It can't commit or push yet, but the clone/fetch/pull functionality is useful. The other issue is that a patched version of ConnectBot needs to be installed before Agit if you want to use SSH keys. If you already have ConnectBot, uninstall it first. I did not do this and ran into problems.

Edit: As of April 2021, the ability to push and pull has been added, however, it does seem to be very buggy as I have only been able to pull changes, but never push them.

Solution 2 - Android

Another option is using ASE. There seems to be a full-featured pure python implementation of git at https://github.com/jelmer/dulwich.

Solution 3 - Android

If the device is rooted, you can also use debian's debootstrap ( http://wiki.debian.org/Debootstrap ) application to create a debian/armel image, mount it in your android device and chroot to it, you have aptitude here so any package available for armel can be installed on your device (to install git: aptitude install git). Look here for information on how to install debian for your android: http://lanrat.com/install-debian-on-android/

Solution 4 - Android

You can install https://github.com/termux/termux-app @ https://play.google.com/store/apps/details?id=com.termux, then you just need to open the terminal and type:

  1. apt update
  2. apt install git

enter image description here

Solution 5 - Android

Some other solutions that are now available, besided Agit, since this question was last answered:

  • A git & mercurial client for bitbucket called Bitbeaker

  • A git app from github

  • The Android Java IDE AIDE also has git functionality, so you can download from a git directory and if its an Android app modify and run it aswell.

Solution 6 - Android

You can also try Pocket Git: https://play.google.com/store/apps/details?id=com.aor.pocketgit

Pocket Git supports SSH (with passphrases, but private keys seem to have some issues) and HTTP, cloning, stage, unstage, commit, push and pull; create, delete and merge branches; and it also has a graphical log viewer and can show diffs.

Disclaimer: I'm the developer

Solution 7 - Android

I would suggest to take a look at Gidder. It's Git server implementation for Android with user and repository management and also support dynamic DNS. You can easily store your code in your Android device and access using a WiFi connection.

Solution 8 - Android

A lot of already existing apps have been posted in the answers, but following links might be useful for those looking for their own implementation:

  1. libgit2

    This is a pure C implementation that claims to be highly portable. And the project also describes how to compile the sources for android platform. Now what needs to be done is to write a JNI binding for it. Even an executable binary would be sufficient in some cases.

  2. HTTP (dumb) protocol

    As an alternative, if one's purely interested in read operations from a repository, this protocol can be implemented over HTTP. There is also a smart protocol which depends on ssh and does differential transfers.

  3. JGit Core Sources

    Using just the core package from its sources. All the javax.* dependencies and other incompatible/alien classes will needed to be replaced with android alternatives though. But worth the effort if a pure Java implementation can be ported to android.

Solution 9 - Android

MGit is the successor of SGit, and it works very well for me.

Solution 10 - Android

Update:

Comment underneath this answer by OP- (Nathan Osman)

> unfortunately, I was forced to pull the application after some recent policy changes on the Play Store that required publishers to have their address displayed on the application's store page.


Original Answer

I've just (circa April 2013) published an app on the Play store named GitDroid. The application allows you to do the following:

  • clone remote repositories
  • pull from the remote and merge new revisions
  • view commits and browse files

Overview Tab of GitDroid

The app cannot push to a remote or make local commits yet - this is planned for a future update.

Solution 11 - Android

This is how I would do it:

Well you likely want to define an interface for your synchronization needs.

You implement this interface in C for both desktop and android device (with the help of the NDK) by making the implementation use git (native).

Then, for the Android app, you code a JNI layer on top so that it exposes the interface to Java.

The tricky part would be to have the different git commands compile for Android: you'll have to rewrite makefiles.

Solution 12 - Android

Try SGit, it can commit & push over SSH with pssphrase-less keys and it is available on F-Droid. It is built on top of JGit. It is not perfect (yet) and JGit implementation is not as good as original Git, but looks usable.

Solution 13 - Android

You can install git on android with Termux. Just install from Play Store and run the command:

pkg install git

Reference: https://mvprepublic.com/blog/2020/04/08/how-to-run-git-on-android-devices/

Solution 14 - Android

Update: CubeGit has been removed because of changes inside the Android system and missing time / incentives to update. Please pick one of the alternatives.


One more option is was CubeGit.

We have released CubeGit on Google Play a few days ago.

It is an interface to a cross compiled git binary and also supports local commits and push via ssh/http/https.

Solution 15 - Android

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDaveView Question on Stackoverflow
Solution 1 - AndroidpolymathicaView Answer on Stackoverflow
Solution 2 - AndroidrascalkingView Answer on Stackoverflow
Solution 3 - AndroidemerinoView Answer on Stackoverflow
Solution 4 - AndroiduserView Answer on Stackoverflow
Solution 5 - Androidknowledge_is_powerView Answer on Stackoverflow
Solution 6 - AndroidAndré RestivoView Answer on Stackoverflow
Solution 7 - AndroidantoniyView Answer on Stackoverflow
Solution 8 - AndroidS.D.View Answer on Stackoverflow
Solution 9 - Androidvr3CView Answer on Stackoverflow
Solution 10 - AndroidNathan OsmanView Answer on Stackoverflow
Solution 11 - AndroidGregory PakoszView Answer on Stackoverflow
Solution 12 - AndroidJosef KufnerView Answer on Stackoverflow
Solution 13 - AndroidMonday UdowongView Answer on Stackoverflow
Solution 14 - Androidf0iView Answer on Stackoverflow
Solution 15 - AndroidtianonView Answer on Stackoverflow