forum/How to emulate "one-way sync"s in a direct repo?git-annexhttp://git-annex.branchable.com/forum/How_to_emulate___34__one-way_sync__34__s_in_a_direct_repo__63__/git-annexikiwiki2015-03-01T23:58:19Zcomment 1http://git-annex.branchable.com/forum/How_to_emulate___34__one-way_sync__34__s_in_a_direct_repo__63__/comment_1_c5226964b4b64bd47d888b5616ff970b/joey2014-12-01T23:35:22Z2014-12-01T23:08:56Z
<p>Well, if you set <code>remote.foo.annex-readonly</code> to true, then git-annex
sync won't push changes to the remote named "foo".</p>
<p>You could set that in .git/config, or you could do something like
this to set it only when running the sync:</p>
<p>git -c remote.foo.annex-readonly=true annex sync</p>
<p>I am not sure about a good solution for sync-all-but-deletes.sh,
although it seems like the new <code>git annex proxy</code> could perhaps
be used to build it.</p>
<p>discard-all-my-changes.sh could probably be implemented using the new
<code>git annex proxy</code> command. It would be pretty unsafe though! Maybe
instead make it first commit all local changes, and then use
<code>git annex proxy -- git reset --hard origin/master</code></p>
comment 2http://git-annex.branchable.com/forum/How_to_emulate___34__one-way_sync__34__s_in_a_direct_repo__63__/comment_2_748d243bac14a8d55be4ac324c581c1d/Jarno2014-12-03T20:04:42Z2014-12-03T20:04:42Z
<p>Thank you, <code>remote.foo.annex-readonly</code> looks like a nice solution for the update-changes-from-other.sh!</p>
<p>For discard-all-my-changes.sh, <code>reset --hard</code> through proxy worked otherwise nicely, but it doesn't seem to restore deletions:</p>
<pre><code>$ git annex proxy -- git reset --hard origin/master
HEAD is now at 37aed97 git-annex automatic sync
$ echo "A" > test.txt
$ git annex add test.txt
add test.txt ok
(Recording state in git...)
$ git annex sync
commit ok
pull origin
ok
push origin
Counting objects: 17, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (7/7), done.
Writing objects: 100% (8/8), 783 bytes | 0 bytes/s, done.
Total 8 (delta 4), reused 1 (delta 0)
To ssh://gitannex@serv-gitannex:/home/gitannex/git-annex-test.git
88a25b5..0a8281d git-annex -> synced/git-annex
37aed97..2978dcd annex/direct/master -> synced/master
ok
$ rm test.txt
$ git annex proxy -- git reset --hard origin/master
warning: packfile .git/objects/pack/pack-42568744cdbba46b2dd71a7f37546a52bb26684
4.pack cannot be accessed
HEAD is now at 2978dcd git-annex automatic sync
$ ls test.txt
ls: test.txt: No such file or directory
$ git annex status
D test.txt
$ git annex version
git-annex version: 5.20141128-g70f997e
build flags: Assistant Webapp Webapp-secure Pairing Testsuite S3 WebDAV DNS Feed
s Quvi TDFA CryptoHash
key/value backends: SHA256E SHA1E SHA512E SHA224E SHA384E SKEIN256E SKEIN512E SH
A256 SHA1 SHA512 SHA224 SHA384 SKEIN256 SKEIN512 WORM URL
remote types: git gcrypt S3 bup directory rsync web webdav tahoe glacier ddar ho
ok external
local repository version: 5
supported repository version: 5
upgrade supported from repository versions: 2 3 4
</code></pre>
<p>Note the "pack cannot be accessed" after the second reset.</p>
Properly saving the changes before hard reset..?http://git-annex.branchable.com/forum/How_to_emulate___34__one-way_sync__34__s_in_a_direct_repo__63__/comment_3_cf9234339bad14ad9a9d3027f9066936/Jarno2014-12-03T21:46:23Z2014-12-03T21:46:23Z
<p>BTW, my complete discard-all-my-changes.sh is, at the moment:</p>
<pre><code>git annex add .
git annex proxy -- git commit -m "Temp commit: changes to be discarded on $HOSTNAME."
git annex proxy -- git reset --hard origin/master
git annex get
git -c core.bare=false clean -dfi
</code></pre>
<p>Is that <code>proxy -- git commit</code> even the proper way to save the changes locally before discarding, or will the branch change of the proxied commit always lose the annexed data? While testing, I've noticed that <code>add .</code> followed by <code>proxy -- git commit</code> at least sometimes replaces the contents of the changed file with a hash, with no apparent way to get them back.</p>
<p>Example:</p>
<pre><code>$ echo "test string" >> show-changes.sh
$ git annex add show-changes.sh
add show-changes.sh ok
(Recording state in git...)
$ git annex proxy -- git commit -m "test"
[annex/direct/master a2a594f] test
1 file changed, 1 insertion(+), 1 deletion(-)
$ cat show-changes.sh
..\..\..\..\.git\annex\objects\QG\3J\SHA256E-s313--a05d6ed6cb73f6a95d98606d37e01
4e5b65e86b9fdb8e9fedded7d36a06ea90a.sh\SHA256E-s313--a05d6ed6cb73f6a95d98606d37e
014e5b65e86b9fdb8e9fedded7d36a06ea90a.sh
$ git annex get show-changes.sh
get show-changes.sh (not available)
No other repository is known to contain the file.
failed
git-annex: get: 1 failed
$ git annex fsck show-changes.sh
fsck show-changes.sh (fixing link) ok
(Recording state in git...)
$ cat show-changes.sh
.git\annex\objects\QG\3J\SHA256E-s313--a05d6ed6cb73f6a95d98606d37e014e5b65e86b9f
db8e9fedded7d36a06ea90a.sh\SHA256E-s313--a05d6ed6cb73f6a95d98606d37e014e5b65e86b
9fdb8e9fedded7d36a06ea90a.sh
</code></pre>
comment 4http://git-annex.branchable.com/forum/How_to_emulate___34__one-way_sync__34__s_in_a_direct_repo__63__/comment_4_d899cf35801636e618e4675d91d6104a/Ramon2015-03-01T23:58:19Z2015-03-01T23:58:19Z
<p>But is there a way to have the changes in one node (the "read only") discarded when there are changes in the remote, so that the new version in the remote is propagated to the read only node?
So I guess what I'd like is something like <em>update-changes-from-others.sh</em> (Like sync, but don't commit any local changes. Merge them like sync, don't discard) but without the merging, so discarding any changes as soon as a new version appears in the remote.</p>
<p>I've tried the <code>remote.foo.annex-readonly = true</code> in Android but I am not getting my intended behavior.</p>
<p>For instance, suppose a computer and a Android device (but with direct mode, since working with assistant)</p>
<ul>
<li>Create file in computer</li>
<li>Let it appear in Android</li>
<li>Modify in Android; this change apparently does not propagate back to the computer.</li>
<li>Modify again in computer; sometime later one gets a conflict (file.variant-xxxx and file-variant-yyyy, with the computer getting one of the conflicts as a link that points nowhere).</li>
</ul>
<p>Adding <code>autocommit = false</code> does not help either.</p>