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 ->
i have tried with other editor app but result is same.
what is the problem?
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:
~ $ 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):
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 $