如何在 Android 上使用 Git?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2701078/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 07:00:45  来源:igfitidea点击:

How to use Git on Android?

androidgitsynchronization

提问by Dave

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.

我有一个使用 git 进行同步的桌面应用程序。我也有一个和桌面一样的 android 应用程序,但我不知道如何在它上面做同步部分。我还没有在 android 上找到任何 git 的实现。我找到了一个 jgit,但它的记录不完整,我什至无法提交。

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 应用程序到我的 git 服务器的远程命令,但这对我来说真的是一个笑话。你能告诉我是否存在可以在 android 上使用的任何其他 git 实现吗?如果您有任何想法如何解决这个问题,请告诉我。

采纳答案by rascalking

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

另一种选择是使用 ASE。在https://github.com/jelmer/dulwich 上似乎有一个功能齐全的纯 python 实现。

回答by polymathica

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 ConnectBotneeds 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.

自从这个问题第一次发布以来,市场上已经添加了一个可以检查 Git 存储库的 Android 应用程序,称为Agit。它还不能提交或推送,但克隆/获取/拉功能很有用。另一个问题是,如果您想使用 SSH 密钥,则需要在 Agit 之前安装补丁版本的 ConnectBot。如果您已经有 ConnectBot,请先卸载它。我没有这样做并遇到了问题。

回答by emerino

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/

如果设备已 root,您还可以使用 debian 的 debootstrap ( http://wiki.debian.org/Debootstrap) 应用程序创建一个 debian/armel 映像,将其挂载到您的 android 设备中并 chroot 到它,您在这里有能力任何可用于 armel 的软件包都可以安装在您的设备上(安装 git:aptitude install git)。在此处查看有关如何为您的 android 安装 debian 的信息:http: //lanrat.com/install-debian-on-android/

回答by knowledge_is_power

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

现在可用的其他一些解决方案,除了Agit,因为这个问题最后被回答:

  • A git & mercurial client for bitbucket called Bitbeaker

  • A git app from github

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

  • 一个名为Bitbeaker 的bitbucket 的 git & mercurial 客户端

  • 来自github的 git 应用程序

  • Android Java IDE AIDE也具有 git 功能,因此您可以从 git 目录下载,如果它是 Android 应用程序,也可以修改并运行它。

回答by André Restivo

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

你也可以试试 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.

Pocket Git 支持 SSH(有密码,但私钥似乎有一些问题)和 HTTP、克隆、暂存、取消暂存、提交、推送和拉取;创建、删除和合并分支;它还有一个图形日志查看器,可以显示差异。

Disclaimer: I'm the developer

免责声明:我是开发者

回答by user

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:

你可以安装https://github.com/termux/termux-app@ https://play.google.com/store/apps/details?id=com.termux,然后你只需要打开终端并输入:

  1. apt update
  2. apt install git
  1. apt update
  2. apt install git

enter image description here

在此处输入图片说明

回答by smartwjw

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

MGitSGit的继承者,它对我来说效果很好。

回答by antoniy

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.

我建议看看Gidder。它是 Android 的 Git 服务器实现,具有用户和存储库管理功能,还支持动态 DNS。您可以轻松地将您的代码存储在您的 Android 设备中并使用 WiFi 连接进行访问。

回答by Nathan Osman

Update:

更新:

Commentunderneath this answer by OP- (Nathan Osman)

OP-(内森·奥斯曼)的这个答案下方发表评论

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.

不幸的是,在 Play 商店最近的一些政策更改要求发布商将其地址显示在应用程序的商店页面上之后,我被迫撤下了该应用程序。



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:

我刚刚(大约 2013 年 4 月)在 Play 商店上发布了一个名为GitDroid的应用程序。该应用程序允许您执行以下操作:

  • clone remote repositories
  • pull from the remote and merge new revisions
  • view commits and browse files
  • 克隆远程仓库
  • 从远程拉取并合并新修订
  • 查看提交和浏览文件

Overview Tab of GitDroid

GitDroid 概览选项卡

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

该应用程序还不能推送到远程或进行本地提交 - 这计划用于未来的更新。

回答by S.D.

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.

  1. libgit2

    这是一个纯 C 实现,声称具有高度的可移植性。并且该项目还描述了如何编译android平台的源代码。现在需要做的是为它编写一个 JNI 绑定。在某些情况下,即使是可执行的二进制文件也足够了。

  2. HTTP(哑)协议

    作为替代方案,如果一个人纯粹对存储库中的读取操作感兴趣,则可以通过 HTTP 实现该协议。还有一个智能协议,它依赖于 ssh 并进行差分传输。

  3. JGit 核心资源

    仅使用其来源的核心包。javax.*尽管如此,所有依赖项和其他不兼容/外来类都需要替换为 android 替代品。但是,如果可以将纯 Java 实现移植到 android,则值得付出努力。