Open mshafer1 opened 4 months ago
(would this be better as a discussion? it looks like that GitHub feature is not turned on for this repo)
Thanks for commenting :) No this is quite fine as an issue!
Okay so first things first: you should use the simplest workflow that will work for your use case. If all you want to do is use Alice's shared collection/deck, then just export it within Anki and then have Bob import it. Done.
You should only need to use Ki if both users plan to continuously push and pull from the collection and it is infeasible for them to use the same AnkiWeb account.
As for what Bob needs to do to track some kind of remote deck within his collection, perhaps this example is best to look at:
This is a workflow to create a new remote subdeck on github or some other remote. If you already have one set up, then I believe instead of running subdeck
, you want to instead just git subtree add
the remote with some prefix. You can see an example of the usage of this command at the end of the subdeck
script in the repo.
Then you can follow the example above for merging and pushing.
Apologies the docs are quite outdated and don't reflect this π
If you're using this seriously for a while I'll go in and update them at some point, but at the moment I don't have any users, so it's not a big priority.
Ugh, GitHub didn't let me know there was a response.
Since we're in active study, I expect the deck(s) to grow, so Alice would be continuing to add more definitions/terms in, and Bob would want to have the updates synced in (running a manual command to do this is fine).
I had contemplated running an instance of https://hub.docker.com/r/matb/docker-anki-sync-server but I started getting the impression that ankiweb and anski-sync-server are intended for single use and not so much "Alice is publishing, Bob is pulling, anyone else can pull if they want"....
(very new to anki, just decided it was time for my study tools to be FOSS, so still figuring it all out)
So...., with regular updates, and wanting to "publicize" the decks on GitHub (instead of sharing ankiweb credentials), I think the subtree makes the most sense. I'll give that a test tonight and report back.
Please do βΊοΈ
Yes so just my two cents is that I have a similar workflow with a friend and I just signed into my AnkiWeb account on one of their devices and we sync back and forth. I didn't actually share credentials, and there's very little risk of data loss because even if they accidentally nuke my whole collection, I have lots and lots of frequent backups thanks to Anki's built-in functionality for this.
From: MakerByNight @.> Sent: Wednesday, July 31, 2024 1:55:08 PM To: langfield/ki @.> Cc: langfield @.>; Comment @.> Subject: Re: [langfield/ki] How to publish a deck into anki? (Issue #173)
Ugh, GitHub didn't let me know there was a response. Since we're in active study, I expect the deck(s) to grow, so Alice would be continuing to add more definitions/terms in, and Bob would want to have the updates synced in (running a manual
Ugh, GitHub didn't let me know there was a response.
Since we're in active study, I expect the deck(s) to grow, so Alice would be continuing to add more definitions/terms in, and Bob would want to have the updates synced in (running a manual command to do this is fine).
I had contemplated running an instance of https://hub.docker.com/r/matb/docker-anki-sync-serverhttps://urldefense.com/v3/__https://hub.docker.com/r/matb/docker-anki-sync-server__;!!KGKeukY!w42os-5Y8YX1i9vg6pAbsddFGYe0sAlagpY6YHHN366TWljr-1oP4BTblcdmyXJ6xP8rd3wOIjnR_P2u04UyYw7vyuXS4Q$ but I started getting the impression that ankiweb and anski-sync-server are intended for single use and not so much "Alice is publishing, Bob is pulling, anyone else can pull if they want"....
(very new to anki, just decided it was time for my study tools to be FOSS, so still figuring it all out)
So...., with regular updates, and wanting to "publicize" the decks on GitHub (instead of sharing ankiweb credentials), I think the subtree makes the most sense. I'll give that a test tonight and report back.
β Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/langfield/ki/issues/173*issuecomment-2261056216__;Iw!!KGKeukY!w42os-5Y8YX1i9vg6pAbsddFGYe0sAlagpY6YHHN366TWljr-1oP4BTblcdmyXJ6xP8rd3wOIjnR_P2u04UyYw4UoBPYnw$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AISQNI6ZL5NJSRDNY3NWN5TZPEQHZAVCNFSM6AAAAABK3ELDTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDENRRGA2TMMRRGY__;!!KGKeukY!w42os-5Y8YX1i9vg6pAbsddFGYe0sAlagpY6YHHN366TWljr-1oP4BTblcdmyXJ6xP8rd3wOIjnR_P2u04UyYw5RbNcTeg$. You are receiving this because you commented.Message ID: @.***>
I'm apparently very confused on how git subtrees is supposed to work...
I think I've deduced that I can't really work at a "sub-collection" level, and it needs to be individual decks. Ok.
After adding a bunch of quotes into params in the copy of subdeck
I got through my pipx install (because I'm on Windows, and I have spaces in my deck names), I did
# setup a local repo to push into
mkdir /tmp/osi_model
pushd /tmp/osi_model/
git init --bare
popd
subdeck "Achronyms/" /tmp/osi_model -f
And tha seemed to work (or at least didn't error) So then I ran:
subdeck "Achronyms/" https://github.com/mshafer1/anki__ccna__osi_model.git
Which pushed all the decks... https://github.com/mshafer1/anki__ccna__osi_model.git
...
Looking at it, I see that "achronyms" is a subtree....
So then I made a new repo and manually copied/commited just the relevant files into it: https://github.com/mshafer1/anki__ccna__achronyms
then in my "second profile" test repo
git subtree add -P ccna_achronyms https://github.com/mshafer1/anki__ccna__achronyms.git main
I wound up whiping the deck and running that from my first-profile as well to force it to be a subtree.
I then went into Anki and added a term, ...,
did a ki pull
, saw the new term come into files, ...
... and... ccna_achronyms
is no longer a subtree to push to the new file to GitHub :(
What exactly is subdeck
tyring to accomplish? it looks like it takes the passed deck, sets it up as a repo, then pulls into original "collections" repo as a subtree?
@mshafer1 Apologies for the late reply! You've picked up the workflow pretty well given the lamentable lack of documentation, I'm impressed π
I'm unsure what you mean by "sub-collection", but yes, you need to specify a deck. Of course it can be a top-level deck that includes your entire collection or any subset, so this should be sufficiently flexible for anyone's needs.
because I'm on Windows
Ah, that is a problem. I have quite explicitly dropped compatibility with Windows. However if you're using mkdir
and popd
, I assume perhaps you're using WSL? If so you may be good :) See https://github.com/langfield/ki/pull/150
As for the deck not getting filtered properly, try running each command in the subdeck
script individually. In particular the following line:
https://github.com/langfield/ki/blob/eb32fbd3229dc1a60bcc76a937ad63f3eb869f65/subdeck#L12
Let me know what the output looks like, because it appears you've done most everything else correctly.
The subdeck
script does the following:
Well, mkdir
and pushd/popd
are also available in cmd. I'm not certain whether I opened wsl when I saw it was a Bash script or Git Bash (I'm thinking the latter).
I didn't get a chance to test this last night, and tonight will be busy as well, but I'll plan to try it out tomorrow and report back.
Well, mkdir and pushd/popd are also available in cmd. I'm not certain whether I opened wsl when I saw it was a Bash script or Git Bash (I'm thinking the latter).
Ah my bad! Yes please let me know, @mshafer1! π
@mshafer1 Any luck?
Been hectic here this last week. Hoping to work on this by Monday evening at the latest.
>C:\Users\Admin\AppData\Roaming\Anki2\User 1\collection.anki2
>ki clone "C:\Users\Admin\AppData\Roaming\Anki2\User 1\collection.anki2"
Cloning into 'C:\Users\Admin\Documents\GitHub\ki_working_dir_2\collection_clone\collection'...
Notes: 100%|ββββββββββββββββββββββββββββββββββ| 25/25 [00:00<00:00, 1438.73it/s]
Media: 100%|ββββββββββββββββββββββββββββββββββ| 25/25 [00:00<00:00, 1060.17it/s]
Notes: 100%|βββββββββββββββββββββββββββββββββββ| 25/25 [00:00<00:00, 274.81it/s]
Notetypes: 100%|βββββββββββββββββββββββββββββββββ| 6/6 [00:00<00:00, 333.37it/s]
>dir
Volume in drive C has no label.
Volume Serial Number is DA25-1622
Directory of C:\Users\Admin\Documents\GitHub\ki_working_dir_2\collection_clone
08/19/2024 09:12 PM <DIR> .
08/19/2024 09:12 PM <DIR> ..
08/19/2024 09:12 PM <DIR> collection
0 File(s) 0 bytes
3 Dir(s) 49,741,271,040 bytes free
>cd collection
>dir
Volume in drive C has no label.
Volume Serial Number is DA25-1622
Directory of C:\Users\Admin\Documents\GitHub\ki_working_dir_2\collection_clone\collection
08/19/2024 09:12 PM <DIR> .
08/19/2024 09:12 PM <DIR> ..
08/19/2024 09:12 PM 26 .gitattributes
08/19/2024 09:12 PM <DIR> .github
08/19/2024 09:12 PM 13 .gitignore
08/19/2024 09:12 PM <DIR> .ki
08/19/2024 09:12 PM <DIR> Achronyms
08/19/2024 09:12 PM <DIR> ccna_achronyms
08/19/2024 09:12 PM <DIR> Definitions
08/19/2024 09:12 PM 13,880 models.json
08/19/2024 09:12 PM <DIR> Network Topologies
08/19/2024 09:12 PM <DIR> Subnet Classes
08/19/2024 09:12 PM <DIR> WAN types
08/19/2024 09:12 PM <DIR> _media
3 File(s) 13,919 bytes
11 Dir(s) 49,740,804,096 bytes free
# note, since I messed with the installed copy, I grabbed a source copy of subdeck
# and only added a "set -o verbose" for echoing commands out
Admin@Matthew-Laptop2 MINGW64 ~/Documents/GitHub/ki_working_dir_2/collection_clone/collection (main)
$ ls
Achronyms/ Definitions/ 'Network Topologies'/ 'Subnet Classes'/ 'WAN types'/ _media/ ccna_achronyms/ models.json
Admin@Matthew-Laptop2 MINGW64 ~/Documents/GitHub/ki_working_dir_2/collection_clone/collection (main)
$ subdeck-verbose Achronyms https://github.com/mshafer1/test-ki-achronyms2.git
set -e
subdeck=$(echo "$1" | sed 's,/*$,,')
remote=$2
root=$(git rev-parse --show-toplevel)
rm -rf /tmp/ki
mkdir -p /tmp/ki
cd /tmp/ki
git clone $root $subdeck
Cloning into 'Achronyms'...
done.
cd $subdeck
git subtree split --prefix $subdeck --annotate="($subdeck) " --rejoin
Added dir 'Achronyms'
4471d69c3f127900c4f6bb965b3f8a93290a7d2e
cd $(git rev-parse --show-toplevel)
git remote rm origin
git remote add origin $remote
mkdir -p .github/workflows
cp $root/.github/workflows/jekyll-gh-pages.yml.example .github/workflows/jekyll-gh-pages.yml
git add .github
git commit -m "Add github pages CI workflow"
[main e6a2b8f] Add github pages CI workflow
1 file changed, 53 insertions(+)
create mode 100644 .github/workflows/jekyll-gh-pages.yml
git push -u origin main
Enumerating objects: 49, done.
Counting objects: 100% (49/49), done.
Delta compression using up to 4 threads
Compressing objects: 100% (43/43), done.
Writing objects: 100% (49/49), 8.62 KiB | 551.00 KiB/s, done.
Total 49 (delta 2), reused 0 (delta 0), pack-reused 0 (from 0)
remote: Resolving deltas: 100% (2/2), done.
To https://github.com/mshafer1/test-ki-achronyms2.git
* [new branch] main -> main
branch 'main' set up to track 'origin/main'.
cd $root
git rm -r $subdeck
rm 'Achronyms/models.json'
git commit -m "Remove \`$subdeck\`"
[main d479776] Remove `Achronyms`
1 file changed, 1 deletion(-)
delete mode 100644 Achronyms/models.json
rm -rf $subdeck
echo "Just deleted prefix"
Just deleted prefix
git subtree add --prefix $subdeck $remote main
git fetch https://github.com/mshafer1/test-ki-achronyms2.git main
remote: Enumerating objects: 9, done.
remote: Counting objects: 100% (9/9), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 6 (delta 1), reused 5 (delta 0), pack-reused 0 (from 0)
Unpacking objects: 100% (6/6), 770 bytes | 15.00 KiB/s, done.
From https://github.com/mshafer1/test-ki-achronyms2
* branch main -> FETCH_HEAD
Added dir 'Achronyms'
echo "commits for deck '$subdeck' pushed to '$remote'"
commits for deck 'Achronyms' pushed to 'https://github.com/mshafer1/test-ki-achronyms2.git'
@mshafer1 Well it looked like it ran without any issues. Are you still seeing any unexpected behavior?
Maybe I'm not expecting correctly?
It cloned the full repo to the "dest', did I misunderstand that it was supposed to turn a folder into a sub-tree and push it?
I see! Can you post the output of ls before and after the git subtree split command? No need to run anything after that.
From: MakerByNight @.> Sent: Tuesday, August 20, 2024 11:19:26 PM To: langfield/ki @.> Cc: langfield @.>; Comment @.> Subject: Re: [langfield/ki] How to publish a deck into anki? (Issue #173)
Maybe I'm not expecting correctly? It cloned the full repo to the "dest', did I misunderstand that it was supposed to turn a folder into a sub-tree and push it? β Reply to this email directly, view it on GitHub, or unsubscribe. You are
Maybe I'm not expecting correctly?
It cloned the full repo to the "dest', did I misunderstand that it was supposed to turn a folder into a sub-tree and push it?
β Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/langfield/ki/issues/173*issuecomment-2300510513__;Iw!!KGKeukY!wOWMuWZ-IS0Jqi_-yzHuL3zQUrr51o9SMBYKvYGJauFwHPgMrbBspPg3B8KayuDtomAHhMDicWYUscLRFC-CGTdw_E5O1A$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AISQNI5XLOPW5ZPVBGUKPO3ZSQBL5AVCNFSM6AAAAABK3ELDTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBQGUYTANJRGM__;!!KGKeukY!wOWMuWZ-IS0Jqi_-yzHuL3zQUrr51o9SMBYKvYGJauFwHPgMrbBspPg3B8KayuDtomAHhMDicWYUscLRFC-CGTfJIZAedA$. You are receiving this because you commented.Message ID: @.***>
(setup with a completely fresh ki clone
again)
Admin@Matthew-Laptop2 MINGW64 ~/Documents/GitHub/ki_working_dir_3/collection (main)
$ subdeck-verbose Achronyms https://github.com/mshafer1/test-ki-achronyms3.git
set -e
subdeck=$(echo "$1" | sed 's,/*$,,')
remote=$2
root=$(git rev-parse --show-toplevel)
rm -rf /tmp/ki
mkdir -p /tmp/ki
cd /tmp/ki
git clone $root $subdeck
Cloning into 'Achronyms'...
done.
cd $subdeck
ls
Achronyms Definitions 'Network Topologies' 'Subnet Classes' 'WAN types' ccna_achronyms models.json netmasks
git subtree split --prefix $subdeck --annotate="($subdeck) " --rejoin
Added dir 'Achronyms'
1c28a7bdda887ca436373e1bfc7a08af4409422f
ls
Achronyms Definitions 'Network Topologies' 'Subnet Classes' 'WAN types' ccna_achronyms models.json netmasks
exit 0
Admin@Matthew-Laptop2 MINGW64 ~/Documents/GitHub/ki_working_dir_3/collection (main)
$ ls -al
total 46
drwxr-xr-x 1 Admin 197121 0 Aug 24 07:59 ./
drwxr-xr-x 1 Admin 197121 0 Aug 24 07:59 ../
drwxr-xr-x 1 Admin 197121 0 Aug 24 07:59 .git/
-rw-r--r-- 1 Admin 197121 26 Aug 24 07:59 .gitattributes
drwxr-xr-x 1 Admin 197121 0 Aug 24 07:59 .github/
-rw-r--r-- 1 Admin 197121 13 Aug 24 07:59 .gitignore
drwxr-xr-x 1 Admin 197121 0 Aug 24 07:59 .ki/
drwxr-xr-x 1 Admin 197121 0 Aug 24 07:59 Achronyms/
drwxr-xr-x 1 Admin 197121 0 Aug 24 07:59 Definitions/
drwxr-xr-x 1 Admin 197121 0 Aug 24 07:59 'Network Topologies'/
drwxr-xr-x 1 Admin 197121 0 Aug 24 07:59 'Subnet Classes'/
drwxr-xr-x 1 Admin 197121 0 Aug 24 07:59 'WAN types'/
drwxr-xr-x 1 Admin 197121 0 Aug 24 07:59 _media/
drwxr-xr-x 1 Admin 197121 0 Aug 24 07:59 ccna_achronyms/
-rw-r--r-- 1 Admin 197121 13880 Aug 24 07:59 models.json
drwxr-xr-x 1 Admin 197121 0 Aug 24 07:59 netmasks/
Admin@Matthew-Laptop2 MINGW64 ~/Documents/GitHub/ki_working_dir_3/collection (main)
$ nano /c/Users/Admin/.local/bin/subdeck-verbose
Admin@Matthew-Laptop2 MINGW64 ~/Documents/GitHub/ki_working_dir_3/collection (main)
$ cd Achronyms/
Admin@Matthew-Laptop2 MINGW64 ~/Documents/GitHub/ki_working_dir_3/collection/Achronyms (main)
$ git status
On branch main
nothing to commit, working tree clean
Admin@Matthew-Laptop2 MINGW64 ~/Documents/GitHub/ki_working_dir_3/collection/Achronyms (main)
$ git remote -v
Admin@Matthew-Laptop2 MINGW64 ~/Documents/GitHub/ki_working_dir_3/collection/Achronyms (main)
$ cd ..
Admin@Matthew-Laptop2 MINGW64 ~/Documents/GitHub/ki_working_dir_3/collection (main)
$ git log Achronyms/
commit 593258f499e91ae2b6b4fc9f335c3bea1fb47509 (HEAD -> main, tag: last-successful-ki-push)
Author: mshafer1 <2565361+mshafer1@users.noreply.github.com>
Date: Sat Aug 24 07:59:04 2024 -0500
Initial commit
Admin@Matthew-Laptop2 MINGW64 ~/Documents/GitHub/ki_working_dir_3/collection (main)
$ git log Definitions/
commit 593258f499e91ae2b6b4fc9f335c3bea1fb47509 (HEAD -> main, tag: last-successful-ki-push)
Author: mshafer1 <2565361+mshafer1@users.noreply.github.com>
Date: Sat Aug 24 07:59:04 2024 -0500
Initial commit
Playing with this a little bit and reading the sub-tree man page...
Is it conceivable that this line: https://github.com/langfield/ki/blob/eb32fbd3229dc1a60bcc76a937ad63f3eb869f65/subdeck#L15C1-L15C30
should be doing a subtree push instead of a push??
like git subtree push --prefix="$subdeck" $remote main
?
Also confirmed that behavior is the same between Git Bash and WSL
I believe something is going wrong with git subtree split. Only the directory in question should remain after that command. (And indeed this is the behavior I see on my machine.) Can you print out the local branches before and after and see if they differ?
From: MakerByNight @.> Sent: Saturday, August 24, 2024 9:30:28 AM To: langfield/ki @.> Cc: langfield @.>; Comment @.> Subject: Re: [langfield/ki] How to publish a deck into anki? (Issue #173)
Also confirmed that behavior is the same between Git Bash and WSL β Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.βMessage ID: langfield/ki/issues/173/2308396264@βgithub.βcom
Also confirmed that behavior is the same between Git Bash and WSL
β Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/langfield/ki/issues/173*issuecomment-2308396264__;Iw!!KGKeukY!3b9KmFa7y3f3eqxtrypbfIWKZ6TH6zv_Z7_XSV7VLxq6CJdlviAFaT7qomPh_gYr-8iLXcjYBJU5ikhd0mwUWNkO2-rZ3A$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AISQNI2OYIWFBRZTMUP5HOLZTCDHJAVCNFSM6AAAAABK3ELDTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBYGM4TMMRWGQ__;!!KGKeukY!3b9KmFa7y3f3eqxtrypbfIWKZ6TH6zv_Z7_XSV7VLxq6CJdlviAFaT7qomPh_gYr-8iLXcjYBJU5ikhd0mwUWNnh2eYpAg$. You are receiving this because you commented.Message ID: @.***>
Apologies that this isn't working out of the box!
From: Whitaker, Brendan T. @.> Sent: Saturday, August 24, 2024 9:56:55 AM To: langfield/ki @.> Subject: Re: [langfield/ki] How to publish a deck into anki? (Issue #173)
I believe something is going wrong with git subtree split. Only the directory in question should remain after that command. (And indeed this is the behavior I see on my machine.) Can you print out the local branches before and after and see if they differ?
From: MakerByNight @.> Sent: Saturday, August 24, 2024 9:30:28 AM To: langfield/ki @.> Cc: langfield @.>; Comment @.> Subject: Re: [langfield/ki] How to publish a deck into anki? (Issue #173)
Also confirmed that behavior is the same between Git Bash and WSL β Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.βMessage ID: langfield/ki/issues/173/2308396264@βgithub.βcom
Also confirmed that behavior is the same between Git Bash and WSL
β Reply to this email directly, view it on GitHubhttps://urldefense.com/v3/__https://github.com/langfield/ki/issues/173*issuecomment-2308396264__;Iw!!KGKeukY!3b9KmFa7y3f3eqxtrypbfIWKZ6TH6zv_Z7_XSV7VLxq6CJdlviAFaT7qomPh_gYr-8iLXcjYBJU5ikhd0mwUWNkO2-rZ3A$, or unsubscribehttps://urldefense.com/v3/__https://github.com/notifications/unsubscribe-auth/AISQNI2OYIWFBRZTMUP5HOLZTCDHJAVCNFSM6AAAAABK3ELDTWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBYGM4TMMRWGQ__;!!KGKeukY!3b9KmFa7y3f3eqxtrypbfIWKZ6TH6zv_Z7_XSV7VLxq6CJdlviAFaT7qomPh_gYr-8iLXcjYBJU5ikhd0mwUWNnh2eYpAg$. You are receiving this because you commented.Message ID: @.***>
In the temp repo?
Admin@Matthew-Laptop2 MINGW64 /tmp/ki/Achronyms (main)
$ git branch -v
* main 685c646 Split 'Achronyms/' into commit '1c28a7bdda887ca436373e1bfc7a08af4409422f'
Relatedly, what is the Git version you have?
I haven't forgotten about this! Just a tad busy at the moment π
I looked into this today and I simply don't have the time to investigate a fix with the proper care. If indeed a modified command of the form git subtree push
works for you, if you write a test for it and submit a PR I'd be happy to merge it :)
Situation I'm trying to do: Alice creates a collection and wants to share it (ki clone, then publish to GitHub)
Bob wants to pull in Alice's collection.
From what I've gathered so far...
Bob could need to :
ki clone
on existing collection./anki_decks
)git sugmodule add https://github.com/mshafer1/anki__ccna.git
(or wherever Alice published)How does Bob then use ki to push this into Anki?