I'd like to provide a team of some non-technical Windows (=direct mode) users with the following git-shell scripts to make collaboration safer than with plain "sync":
1) update-changes-from-others.sh -- Like sync, but don't commit any local changes. Merge them like sync, don't discard.
2) sync-all-but-deletes.sh -- Like sync but don't commit any deletions (-> renames may become additions).
3) discard-all-my-changes.sh -- Forcibly discard all local changes, then checkout and get latest master head.
Any pointers on how to approach implementing these safely?
Well, if you set
remote.foo.annex-readonly
to true, then git-annex sync won't push changes to the remote named "foo".You could set that in .git/config, or you could do something like this to set it only when running the sync:
git -c remote.foo.annex-readonly=true annex sync
I am not sure about a good solution for sync-all-but-deletes.sh, although it seems like the new
git annex proxy
could perhaps be used to build it.discard-all-my-changes.sh could probably be implemented using the new
git annex proxy
command. It would be pretty unsafe though! Maybe instead make it first commit all local changes, and then usegit annex proxy -- git reset --hard origin/master
Thank you,
remote.foo.annex-readonly
looks like a nice solution for the update-changes-from-other.sh!For discard-all-my-changes.sh,
reset --hard
through proxy worked otherwise nicely, but it doesn't seem to restore deletions:Note the "pack cannot be accessed" after the second reset.
BTW, my complete discard-all-my-changes.sh is, at the moment:
Is that
proxy -- git commit
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 thatadd .
followed byproxy -- git commit
at least sometimes replaces the contents of the changed file with a hash, with no apparent way to get them back.Example:
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 update-changes-from-others.sh (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.
I've tried the
remote.foo.annex-readonly = true
in Android but I am not getting my intended behavior.For instance, suppose a computer and a Android device (but with direct mode, since working with assistant)
Adding
autocommit = false
does not help either.