我有一个使用 git 进行同步的桌面应用程序。我还有一个 Android 应用程序,其功能与桌面相同,但我不知道如何在其上执行同步部分。我还没有在 Android 上找到任何 git 的实现。我找到了一个 jgit,但它的记录不完善,我什至无法用它进行提交。
我正在考虑从我的 Android 应用程序到我的 git 服务器的远程命令,但这对我来说确实是一个挑逗。
你能告诉我是否存在其他可以在 android 上使用的 git 实现吗?如果您知道如何解决该问题,请告诉我。
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.
发布评论
评论(15)
自从这个问题首次发布以来,市场上已经添加了一个 Android 应用程序,可以查看 Git 存储库,名为 激动。它还不能提交或推送,但克隆/获取/拉取功能很有用。另一个问题是 ConnectBot 的修补版本 需要如果您想使用 SSH 密钥,请在 Agit 之前安装。如果您已经安装了 ConnectBot,请先将其卸载。我没有这样做并遇到了问题。
编辑:截至 2021 年 4 月,添加了推送和拉取的功能,但是,它似乎确实有很多问题,因为我只能拉取更改,但不能推送它们。
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.
您可以安装 https://github.com/termux/termux -app?tab=readme-ov-file#installation,那么你只需要打开终端并输入:
apt update
apt install git
You can install https://github.com/termux/termux-app?tab=readme-ov-file#installation, then you just need to open the terminal and type:
apt update
apt install git
另一种选择是使用 ASE。 https://github.com/jelmer/dulwich。
Another option is using ASE. There seems to be a full-featured pure python implementation of git at https://github.com/jelmer/dulwich.
如果设备已 root,您还可以使用 debian 的 debootstrap ( http://wiki.debian.org/Debootstrap ) 应用程序来创建 debian/armel 映像,将其安装到您的 Android 设备中并对其进行 chroot,您在这里拥有 aptitude,因此可以在您的设备上安装任何可用于 armel 的软件包(要安装 git: aptitude install git)。请在此处查看有关如何为 Android 安装 debian 的信息:http://lanrat.com/install -debian-on-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/
您还可以尝试 Pocket Git:https://play.google .com/store/apps/details?id=com.aor.pocketgit
Pocket Git 支持 SSH(有密码,但私钥似乎有一些问题)和 HTTP、克隆、阶段、取消阶段、提交、推送和拉;创建、删除和合并分支;它还有一个图形日志查看器,可以显示差异。
免责声明:我是开发商
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
除了 Agit 之外,现在还提供了一些其他解决方案,因为这个问题最后被回答了:
A git & Bitbucket 的 Mercurial 客户端,名为 Bitbeaker< /p>
Android Java IDE AIDE< /a> 还具有 git 功能,因此您可以从 git 目录下载,如果它是 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.
许多现有的应用程序已发布在答案中,但以下链接对于那些寻找自己的实现的人可能有用:
libgit2
这是一个纯 C 实现,号称具有高度可移植性。该项目还描述了如何编译android平台的源代码。现在需要做的是为其编写 JNI 绑定。在某些情况下,即使是可执行的二进制文件也足够了。
HTTP(哑)协议
作为替代方案,如果纯粹对存储库中的读取操作感兴趣,则可以通过 HTTP 实现此协议。还有一个依赖于 ssh 并进行差分传输的智能协议。
JGit 核心源
仅使用其来源中的核心包。不过,所有
javax.*
依赖项和其他不兼容/外来类都需要用 android 替代品替换。但如果纯 Java 实现可以移植到 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:
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.
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.
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.我建议您查看 Gidder。它是 Android 的 Git 服务器实现,具有用户和存储库管理功能,还支持动态 DNS。您可以轻松地将代码存储在 Android 设备中并使用 WiFi 连接进行访问。
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.
MGit 是 SGit 的继承者,它对我来说非常有用。
MGit is the successor of SGit, and it works very well for me.
更新:
下面的评论 OP-(内森·奥斯曼)的回答
原始答案
I'我刚刚(大约 2013 年 4 月)在 Play 商店上发布了一款名为 GitDroid.该应用程序允许您执行以下操作:
该应用程序还无法推送到远程或进行本地提交 - 这是计划在未来更新的。
Update:
Comment underneath this answer by OP- (Nathan Osman)
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:
The app cannot push to a remote or make local commits yet - this is planned for a future update.
我会这样做:
那么您可能想要定义一个接口来满足您的同步需求。
您可以通过使用 git(本机)来使用 C 语言为桌面和 Android 设备(在 NDK 的帮助下)实现此接口。
然后,对于 Android 应用程序,您在顶部编写 JNI 层,以便将接口公开给 Java。
棘手的部分是为 Android 编译不同的 git 命令:您必须重写 makefile。
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.
尝试SGit,它可以提交&使用无密码密钥通过 SSH 推送,可在 F-Droid 上使用。它构建在 JGit 之上。它还不完美,JGit 实现不如原始 Git,但看起来可用。
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.
您可以使用 Termux 在 Android 上安装 git。只需从 Play 商店安装并运行命令:
参考:https://mvprepublic.com/blog/2020/04/08/how-to-run-git-on-android-devices/
You can install git on android with Termux. Just install from Play Store and run the command:
Reference: https://mvprepublic.com/blog/2020/04/08/how-to-run-git-on-android-devices/
更新: CubeGit 已被删除,因为 Android 系统内部发生了变化并且缺少更新的时间/激励。
请选择其中一项。
另一种选择是 CubeGit。
我们已在 Google Play 上发布
CubeGit几天前。它是交叉编译的 git 二进制文件的接口,还支持通过 ssh/http/https 进行本地提交和推送。
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
iswas CubeGit.We have released
CubeGit on Google Playa few days ago.It is an interface to a cross compiled git binary and also supports local commits and push via ssh/http/https.
JGit - http://eclipse.org/jgit/
JGit - http://eclipse.org/jgit/