116 lines
4.4 KiB
Markdown
116 lines
4.4 KiB
Markdown
While git-annex can be [[installed_on_your_Android_device|/Android]],
|
|
it might be easier not to install it there, but run it on your computer
|
|
using `adb` to pull and push changes to the Android device.
|
|
|
|
A few reasons for going this route:
|
|
|
|
* Easier than installing git-annex on Android.
|
|
* Avoids needing to type commands into a terminal on Android.
|
|
* Avoids problems with putting a git-annex repository on Android's `/sdcard`,
|
|
which is crippled by not supporting hard links etc.
|
|
|
|
All you should need is a USB cable (or adb over wifi), and the `adb`
|
|
command.
|
|
|
|
## setting it up
|
|
|
|
First, initialize your git-annex repository on your computer, if you haven't
|
|
already.
|
|
|
|
Then, in that repository, set up an adb special remote:
|
|
|
|
initremote android type=adb androiddirectory=/sdcard encryption=none exporttree=yes importtree=yes
|
|
|
|
The above example syncs with the /sdcard directory of the
|
|
Android device. That can be a lot of files, so you may want a more
|
|
limited directory. See the sample workflows below for some more examples.
|
|
|
|
Next, configure how trees of files imported from it will be merged into your
|
|
git repository.
|
|
|
|
git config remote.android.annex-tracking-branch master:android
|
|
|
|
Setting "master:android" makes the phone be treated as containing a branch
|
|
of the master branch, and makes all its files appear to be inside a
|
|
subdirectory named `android`. If you want its files to not be in a
|
|
subdirectory, set it to "master" instead.
|
|
|
|
Finally, you may want to configure a preferred content expression for the
|
|
remote. That will limit both what is exported to it, and what is imported
|
|
from it. If you want to fully sync all files, you don't need to do this.
|
|
|
|
For example, to limit the files that get imported and exported to sound files:
|
|
|
|
git annex wanted android 'include=*.mp3 or include=*.ogg'
|
|
|
|
## syncing with it
|
|
|
|
git annex sync --content android
|
|
|
|
This command does a bi-directional sync with the phone, first importing
|
|
new and changed files from it, merging that into the master branch,
|
|
and then exporting from the master branch back to the android device so any
|
|
modifications you have made get synced over to it.
|
|
|
|
See [[git-annex-import, [[git-annex-export]], and [[git-annex-sync]]
|
|
for more details, and bear in mind that you can also use commands like
|
|
these to only import from or export to the android device:
|
|
|
|
git annex import master:android --from android
|
|
git merge android/master
|
|
git annex export master:android --to android
|
|
|
|
## sample workflows
|
|
|
|
### photos
|
|
|
|
Set up the remote to use the /sdcard/DCIM directory where the phone's
|
|
camera stores them.
|
|
|
|
initremote android type=adb androiddirectory=/sdcard/DCIM encryption=none exporttree=yes importtree=yes
|
|
|
|
The annex-tracking-branch can be the same as before, to limit
|
|
the files that are synced to those in an android directory:
|
|
|
|
git config remote.android.annex-tracking-branch master:android
|
|
|
|
If you don't want to keep old photos on your Android device, you can simply
|
|
`git mv` the files from the android directory to another directory, and
|
|
the next sync with the phone will delete them from the Android device:
|
|
|
|
git mv android/* .
|
|
git annex sync --content
|
|
|
|
### music and podcasts
|
|
|
|
You could set up the remote to use the /sdcard/Music directory.
|
|
But, I sometimes download music to other locations, and perhaps you do too.
|
|
Let's instead limit the remote to mp3 and ogg files:
|
|
|
|
initremote android type=adb androiddirectory=/sdcard encryption=none exporttree=yes importtree=yes
|
|
git annex wanted android 'include=*.mp3 or include=*.ogg'
|
|
|
|
The annex-tracking-branch can be the same as before, to limit
|
|
the files that are synced to those in an android directory:
|
|
|
|
git config remote.android.annex-tracking-branch master:android
|
|
|
|
And then do an initial sync:
|
|
|
|
git annex sync --content android
|
|
|
|
Now, you can copy music and podcasts you want to listen
|
|
to over to the Android device, by first copying them to the android
|
|
directory of your git-annex repo:
|
|
|
|
cp -a podcasts/LibreLounge/Episode_14__Secure_Scuttlebutt_with_Joey_Hess.ogg android/
|
|
git annex add android
|
|
git annex sync --content android
|
|
|
|
That will also import any new sound files from the Android device into
|
|
your git-annex repo.
|
|
|
|
Once you're done with listening to something on the Android device, you can
|
|
simply delete it from the device, and the next time git-annex syncs, it
|
|
will get removed from the android directory. Or, you can delete it from the
|
|
android directory and the next sync will delete it from the Android device.
|