How to use Git on Android?
Asked Answered
G

15

90

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.

Girder answered 23/4, 2010 at 18:33 Comment(4)
sry, no time to answer; what about Terminal IDE? see lox-o-drome.blogspot.de/2012/08/…Exeunt
@YAK Sadly, Terminal IDE doesn't seem to be maintained anymore. At least it isn't working since I upgraded to Lollipop.Boulevardier
@Boulevardier the huge "** CURRENTLY INCOMPATIBLE WITH ANDROID 5.0 LOLLIPOP **" in the description in the play store indicates that it is still maintained and that a fix might arrive some dayExeunt
@YAK Hidden below the fold for me, I'm afraid. Had to click into the full description to see it. Huge = all-caps, fair enough.Boulevardier
T
14

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

Tupper answered 23/4, 2010 at 19:46 Comment(3)
but how to install dulwich on ASE? ASE is just for scripts, it cant be used for run real applications, at least not yet I ve tried it, but module distutils.core not found....Girder
From code.google.com/p/android-scripting/wiki/FAQ: Can I install other Python modules? Yes. Many pure Python modules will work if you simply add them to /sdcard/ase/extras/python as long as they don't depend on any C Python modules that aren't included with ASE. You can, of course, cross compile your own C Python modules. But, that's not for the faint of heart. Python eggs will need to be manually installed. That is, you will need to copy the Python modules to their appropriate location manually. ASE does not support easy_install.Tupper
Is there a recent update to this? ASE stopped in 2015Gush
S
20

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.

Stickweed answered 22/6, 2011 at 21:14 Comment(4)
Hi, I'm the author of Agit - I just wanted to mention there are SSH setup instructions for Agit here - I've also improved the app since then so that it gives you more guidance if it can't find an already installed SSH agent :)Eileen
Link to Agit is dead.Pinwork
Here's the link to source code: github.com/rtyley/agit and it's also available on F-Droid. Last update was like 6 years ago tho.Paginal
Is there an update to how agit and connectbot work with this? I can't get this option to work but agit seems greatGush
W
16

You can install https://github.com/termux/termux-app?tab=readme-ov-file#installation, then you just need to open the terminal and type:

  1. apt update
  2. apt install git

enter image description here

Wavemeter answered 22/7, 2018 at 9:55 Comment(0)
T
14

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

Tupper answered 23/4, 2010 at 19:46 Comment(3)
but how to install dulwich on ASE? ASE is just for scripts, it cant be used for run real applications, at least not yet I ve tried it, but module distutils.core not found....Girder
From code.google.com/p/android-scripting/wiki/FAQ: Can I install other Python modules? Yes. Many pure Python modules will work if you simply add them to /sdcard/ase/extras/python as long as they don't depend on any C Python modules that aren't included with ASE. You can, of course, cross compile your own C Python modules. But, that's not for the faint of heart. Python eggs will need to be manually installed. That is, you will need to copy the Python modules to their appropriate location manually. ASE does not support easy_install.Tupper
Is there a recent update to this? ASE stopped in 2015Gush
S
11

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/

Strenta answered 11/10, 2011 at 5:5 Comment(0)
G
9

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

Gandzha answered 16/11, 2014 at 21:0 Comment(7)
an Pocket Git use binary files from Android filesystem and push it to git repo? Will it work with single file repo such as the ones on gist.github.com?Baywood
It works with gists (just tested cloning, changing, staging, committing and pushing). Not sure if I understood your first question. You can clone any repo, change any file (pocket git does not provide any editor but you can open the files with other apps), stage, commit and push back to the repo.Alphonse
I just bought your app and did some tests. All works fine. The only thing I was expecting was create new file via pointing to existing one on the device. Anyway I achieved needed I wanted by using ES file explorer to copy a file to the git repo folder and pushing it using yours PocketGit. Great app. Thank you.Baywood
I bought this, but unfortunately it produces an error when trying to clone using a private key (which works in other clients), and I do not want to input my password. No response from the developer. My advice would be to use the two day Google refund window to check this app does what you need.Surname
@adam - what alternative are you using that works? You said other clients, which ones? Can you use ssh keys? With passphrase? And push, pull, clone, commit?Gush
@andré-restivo how do you get pocketgut to work with current os and ssh keys?Gush
Hey All and @adam, I was able to get this to work. The issue I was running into was the ssh key. I wanted to maintain my own and this create my own. I found that it only accepts RSA, but I had to up the byte to 4096 and then supply a username and password even if that PW is blank. And there was one other option I had to mark and I forget.Gush
S
8

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.

Semantic answered 27/7, 2012 at 15:42 Comment(1)
AIDE supports push as well, but only in the premium version. Github and Bitbeaker apps are read-only AFAICT.Morphophoneme
S
7

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.

Show answered 27/7, 2015 at 11:26 Comment(0)
H
6

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.

Hydrometallurgy answered 4/9, 2012 at 13:25 Comment(2)
That looks great, but it doesn't seem to have any way to commit changes... is that possible? If not, it seems a bit pointless being able to push...Whiskey
@Hydrometallurgy Can I choose a folder on sd card on git repo?Girdle
G
6

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

Gorge answered 4/2, 2017 at 7:31 Comment(3)
Quite a buggy application though.Whitten
Do you have more details on mgit working for you? Trying with ssh keys don't seem to workGush
I was able to get this to work, some issue and comment for pocketgit. I wanted to mange my own created ssh keys and I needed to make them RSA with a byte of 4096 and supply the username and password (even if the PW is blank) and there was one other flag I had to set, if I remember or see it I will add it here. Typical I use ed25519, and trying to use it and create it on multiple Linux OS, Mac, Android in termux, and Windows failed and so did just RSA 2048Gush
F
4

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.

Ferrate answered 8/4, 2013 at 22:54 Comment(4)
future here refers to something that is still in the future, When can expect push to be implemented?Exeunt
@Maximus 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.Ferrate
Frankly this requirement is stupid - a lot of individual developers are not going to publish their home address for everyone to see!Lipocaic
How about F-Droid?Nicaea
S
2

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.

Skiascope answered 23/4, 2010 at 18:39 Comment(0)
W
2

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.

Woodford answered 10/9, 2016 at 7:14 Comment(1)
sgit is dead. This is the successor: github.com/maks/MGitPinwork
F
2

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/

Finbur answered 28/4, 2020 at 7:53 Comment(1)
Installing termux from the google play store is no longer recommended by the maintainers: github.com/termux/…Inexplicit
B
1

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.

Boonie answered 20/11, 2013 at 15:57 Comment(1)
App not available on playstore.Whitten
M
0

JGit - http://eclipse.org/jgit/

Medication answered 28/8, 2010 at 6:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.