2019-04-09 21:45:55 +00:00
|
|
|
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:
|
|
|
|
|
2019-05-21 18:56:45 +00:00
|
|
|
initremote android type=adb androiddirectory=/sdcard encryption=none exporttree=yes importtree=yes
|
2019-04-09 21:45:55 +00:00
|
|
|
|
2019-05-21 18:56:45 +00:00
|
|
|
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.
|
2019-04-09 21:45:55 +00:00
|
|
|
|
2019-05-21 18:56:45 +00:00
|
|
|
Next, configure how trees of files imported from it will be merged into your
|
2019-04-10 16:34:28 +00:00
|
|
|
git repository.
|
2019-04-09 21:45:55 +00:00
|
|
|
|
2019-04-10 16:34:28 +00:00
|
|
|
git config remote.android.annex-tracking-branch master:android
|
2019-04-09 21:45:55 +00:00
|
|
|
|
2019-04-10 16:34:28 +00:00
|
|
|
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.
|
2019-04-09 21:45:55 +00:00
|
|
|
|
2019-05-21 18:56:45 +00:00
|
|
|
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'
|
|
|
|
|
2019-04-10 16:34:28 +00:00
|
|
|
## syncing with it
|
2019-04-09 21:45:55 +00:00
|
|
|
|
2019-04-10 16:34:28 +00:00
|
|
|
git annex sync --content android
|
2019-04-09 21:45:55 +00:00
|
|
|
|
2019-04-10 16:34:28 +00:00
|
|
|
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.
|
2019-04-09 21:45:55 +00:00
|
|
|
|
2019-04-10 16:34:28 +00:00
|
|
|
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:
|
2019-04-09 21:45:55 +00:00
|
|
|
|
2019-04-10 16:34:28 +00:00
|
|
|
git annex import master:android --from android
|
2019-08-09 17:21:15 +00:00
|
|
|
git annex merge android/master
|
2019-04-10 16:34:28 +00:00
|
|
|
git annex export master:android --to android
|
2019-04-09 21:45:55 +00:00
|
|
|
|
|
|
|
## sample workflows
|
|
|
|
|
|
|
|
### photos
|
|
|
|
|
2019-05-21 18:56:45 +00:00
|
|
|
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:
|
2019-04-09 21:45:55 +00:00
|
|
|
|
|
|
|
git mv android/* .
|
|
|
|
git annex sync --content
|
|
|
|
|
|
|
|
### music and podcasts
|
|
|
|
|
2019-05-21 18:56:45 +00:00
|
|
|
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'
|
2019-04-09 21:45:55 +00:00
|
|
|
|
2019-04-10 16:34:28 +00:00
|
|
|
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
|
2019-04-09 21:45:55 +00:00
|
|
|
|
2019-04-10 16:34:28 +00:00
|
|
|
And then do an initial sync:
|
2019-04-09 21:45:55 +00:00
|
|
|
|
2019-04-10 16:34:28 +00:00
|
|
|
git annex sync --content android
|
2019-04-09 21:45:55 +00:00
|
|
|
|
2019-04-10 16:34:28 +00:00
|
|
|
Now, you can copy music and podcasts you want to listen
|
2019-05-21 18:56:45 +00:00
|
|
|
to over to the Android device, by first copying them to the android
|
2019-04-09 21:45:55 +00:00
|
|
|
directory of your git-annex repo:
|
|
|
|
|
|
|
|
cp -a podcasts/LibreLounge/Episode_14__Secure_Scuttlebutt_with_Joey_Hess.ogg android/
|
|
|
|
git annex add android
|
2019-04-10 16:34:28 +00:00
|
|
|
git annex sync --content android
|
2019-04-09 21:45:55 +00:00
|
|
|
|
2019-05-21 18:56:45 +00:00
|
|
|
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
|
2019-04-10 16:34:28 +00:00
|
|
|
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.
|