Sparkleshare and dvcs-autosync are tools to automatically commit your changes to git and keep them in sync with other repositories. Unlike git-annex, they don't store the file content on the side, but directly in the git repository. Great for small files, less good for big files.
Here's how to use the git-annex assistant to do the same thing, but even better!
Let's suppose you're developing a video game, written in C. You have source code, and some large game assets. You want to ensure the source code is stored in git -- that's what git's for! And you want to store the game assets in the git annex -- to avod bloating your git repos with possibly enormous files, but still version control them.
All you need to do is configure git-annex to treat your C files as small files. And treat any file larger than, say, 100kb as a large file that is stored in the annex.
git config annex.largefiles "largerthan=100kb and not (include=*.c or include=*.h)"
For more details about this configuration, see largefiles.
Now if you run git annex add
, it will only add the large files to the
annex; small files will be stored in git.
Or, run git annex assistant
. It will automatically
add the large files to the annex, and store the small files in git.
It'll notice every time you modify a file, and immediately commit it,
too. And sync it out to other repositories you configure using git annex
webapp
.
It's also possible to disable the use of the annex entirely, and just have the assistant always put every file into git, no matter its size:
git config annex.largefiles "exclude=*"
I just gave this feature a try, but it seems it doesn't work as expected or maybe I don't understand it:
Now I copy two files to this directory and add both to the annex
So the picture is added to the annex as expected. But the .txt file is not added to git. Do I have to manually add this to git? And why is the picture seen as new file by git?
The second question could be answered by: "run git annex sync". Is this correct? Because after running this command, git does not see this file as a new file anymore:
Like it says in the tip,
git annex add
will add the large files to git. You can add the small files withgit add
; git-annex won't do that for you.To automatically add both sorts of files, you can use the
git annex watch
orgit annex assistant
daemons. The latter also keeps files in sync between repositories automatically.(Why did the picture show up as a new file in git? Because you hadn't committed it. This is the same as when you
git add
a file; it's only staged in the index;git status
will show it is new until yougit commit
)annex.largefiles
support mimetypes? F.e.git config annex.largefiles "not mimetype=text/plain"
annex.largefiles does not support mime types. I agree it would be a useful addition.
annex.largefiles can be used with direct mode. I would only recommending using it this way using the assistant, which will keep straight which files are which and commit them appropriately.
I've tried this with version 5.20131130, but my files disappear if I modify them on the remote end.
My setup: - A local repository, direct mode, client group, annex.largefiles "exclude=.txt" - A remote one, also direct mode, backup group, annex.largefiles "exclude=.txt" Both are running the assistant.
If I create a .txt file locally, it gets committed and pushed to the remote as described. But, if I then modify that file on the remote end, the file gets deleted from both repositories. Also, if I create a file on the remote end, it's pushed to the local one (according to the log) but it never appears in the directory.
Changing the remote from 'backup' to 'client' group doesn't seem to make any difference.
Is there a 'best practice' on using git-annex like SparkleShare? I mean, syncing changes on all repositories but keeping a history of changes in git.
Thanks!