从Android上的git编辑克隆文件(termux)

发布于 2025-02-01 21:05:44 字数 346 浏览 5 评论 0原文

我有要点,我在Android上使用术语。我克隆了这个要旨。我有TXT文件,我想编辑此文件然后按下,但是当我编辑此文件时,它不起作用,并且文件的上下文是相同的。保存了,但另一个位置和克隆的文件没有更改

这是错误 - >

我已经尝试了其他编辑器应用程序,但结果是相同的。

问题是什么?

I have gist and i use git on android with termux. i have cloned this gist. i have txt file and i want to edit this file and then push, but when i edit this file, it doesn't work and file's context is same.file saved but another location and cloned file didn't changed

this is error ->

image

i have tried with other editor app but result is same.

what is the problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

心如荒岛 2025-02-08 21:05:44

您正在尝试在设备存储(/模拟/存储/...)的GIT工作。不建议这样做,因为Termux无法完全访问您的设备文件。

尝试以下步骤,可能会有所帮助。

1。克隆您的要点在Termux分区中:

  • 不要在〜/storage 中克隆您的存储库
  • ,为此创建一个目录。即:
~ $ cd ~
~ $ mkdir git-repo
~ $ cd git-repo/
~/git-repo $ git clone [email protected]:ef5d373b7982e0173437f2aaf17fef42.git
Cloning into 'ef5d373b7982e0173437f2aaf17fef42'...
Enter passphrase for key '/data/data/com.termux/files/home/.ssh/id_ed255': 
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 9 (delta 0), reused 6 (delta 0), pack-reused 0
Receiving objects: 100% (9/9), done.
~/git-repo $ 

PS。:确保您配置了SSH键。 在文档中检查它。

2。进行更改:

现在,您可以使用 vi 或其他术语实例中的其他编辑器更新文件。但是我相信您想使用手机中的某些图形编辑器应用更新文件,对吗?

为了做到这一点,您必须从手机授予对术语文件的访问。 在此处查看trimux文档。(查找“来自文件管理器的访问术语”)。也许您需要运行这样的命令:

am start -a android.intent.action.VIEW -d "content://com.android.externalstorage.documents/root/primary"

运行此命令后,您应该能够在任何应用程序中访问术语文件。例如,在Acode App IDE中(在屏幕截图下方显示具有访问术语中的文件夹的应用程序):

3。将更新发送回您的git:

好吧,现在您最终可以运行命令“ git add”,“ git commit”,“ git push”等...在下面,我显示了此测试的结果在我的Termux中:

~/git-repo/ef5d373b7982e0173437f2aaf17fef42 $ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   gist-test.txt

no changes added to commit (use "git add" and/or "git commit -a")
~/git-repo/ef5d373b7982e0173437f2aaf17fef42 $ git add .
~/git-repo/ef5d373b7982e0173437f2aaf17fef42 $ git commit -m "test changes to gist from termux"
[main 377fb5c] test changes to gist from termux
 1 file changed, 1 insertion(+), 1 deletion(-)
~/git-repo/ef5d373b7982e0173437f2aaf17fef42 $ git push
Enter passphrase for key '/data/data/com.termux/files/home/.ssh/id_ed25519': 
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 296 bytes | 296.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To gist.github.com:ef5d373b7982e0173437f2aaf17fef42.git
   406a6d0..377fb5c  main -> main
~/git-repo/ef5d373b7982e0173437f2aaf17fef42 $ git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
~/git-repo/ef5d373b7982e0173437f2aaf17fef42 $ 

You are trying to work with git at your device storage (/emulated/storage/...). That's not recommended, because termux doesn't have full access to your device files.

Try the steps below, it may help.

1. clone your gist in termux partition:

  • Do not clone your repo in ~/storage
  • Instead, create a directory for that. i.e:
~ $ cd ~
~ $ mkdir git-repo
~ $ cd git-repo/
~/git-repo $ git clone [email protected]:ef5d373b7982e0173437f2aaf17fef42.git
Cloning into 'ef5d373b7982e0173437f2aaf17fef42'...
Enter passphrase for key '/data/data/com.termux/files/home/.ssh/id_ed255': 
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 9 (delta 0), reused 6 (delta 0), pack-reused 0
Receiving objects: 100% (9/9), done.
~/git-repo $ 

ps.: Be sure you have configured your ssh key. Check it at documentation.

2. make your changes:

Now, you can update your files using vi or other editor inside termux instance. But I believe you want to update your files using some graphic editor app in your phone, right?

In order to do that, you have to grant access to your termux files from your phone. Check the termux documentation here. (look for "Access Termux from a file manager"). Maybe you'll need to run a command like this:

am start -a android.intent.action.VIEW -d "content://com.android.externalstorage.documents/root/primary"

After running this command you should be able to access your termux files inside any app. For instance, in ACode app IDE (below a screenshot showing an app with access to a folder inside termux):

An app showing that there is access to termux files

3. send the updates back to your git:

Ok, now you can finally run the commands "git add", "git commit", "git push", etc... Below I'm showing the result of this test in my termux:

~/git-repo/ef5d373b7982e0173437f2aaf17fef42 $ git status
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
    modified:   gist-test.txt

no changes added to commit (use "git add" and/or "git commit -a")
~/git-repo/ef5d373b7982e0173437f2aaf17fef42 $ git add .
~/git-repo/ef5d373b7982e0173437f2aaf17fef42 $ git commit -m "test changes to gist from termux"
[main 377fb5c] test changes to gist from termux
 1 file changed, 1 insertion(+), 1 deletion(-)
~/git-repo/ef5d373b7982e0173437f2aaf17fef42 $ git push
Enter passphrase for key '/data/data/com.termux/files/home/.ssh/id_ed25519': 
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Writing objects: 100% (3/3), 296 bytes | 296.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
To gist.github.com:ef5d373b7982e0173437f2aaf17fef42.git
   406a6d0..377fb5c  main -> main
~/git-repo/ef5d373b7982e0173437f2aaf17fef42 $ git status
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
~/git-repo/ef5d373b7982e0173437f2aaf17fef42 $ 
写下不归期 2025-02-08 21:05:44

对我来说,GH身份验证工作。

安装GH PKG安装GH

然后GH auth登录用#ssh#for登录填充提示符。

然后登录。

然后,对于git clone正确检查地址是否正确,有时在副本上丢失了拼写,请检查。它应该起作用。

For me gh authentication worked.

Install gh pkg install gh

Then gh auth login fill the prompt with #ssh# for login.

Then do login.

Then for git clone properly check if the address is put right, sometimes with copy-paste the spelling gets lost, so check. And it should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文