From 7b9762b6afc6cfb954bc73f1a6265b5a792b0454 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 9 Aug 2018 15:05:19 -0400 Subject: [PATCH] document converting from git to annex and back --- ..._8ab0f0852a1dc6c51a502f07faba61eb._comment | 8 +++++ doc/tips/largefiles.mdwn | 31 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 doc/bugs/cannot_commit___34__annex_add__34__ed_modified_file_which_switched_its_largefile_status_to_be_committed_to_git_now/comment_4_8ab0f0852a1dc6c51a502f07faba61eb._comment diff --git a/doc/bugs/cannot_commit___34__annex_add__34__ed_modified_file_which_switched_its_largefile_status_to_be_committed_to_git_now/comment_4_8ab0f0852a1dc6c51a502f07faba61eb._comment b/doc/bugs/cannot_commit___34__annex_add__34__ed_modified_file_which_switched_its_largefile_status_to_be_committed_to_git_now/comment_4_8ab0f0852a1dc6c51a502f07faba61eb._comment new file mode 100644 index 0000000000..7a3436b636 --- /dev/null +++ b/doc/bugs/cannot_commit___34__annex_add__34__ed_modified_file_which_switched_its_largefile_status_to_be_committed_to_git_now/comment_4_8ab0f0852a1dc6c51a502f07faba61eb._comment @@ -0,0 +1,8 @@ +[[!comment format=mdwn + username="joey" + subject="""comment 4""" + date="2018-08-09T19:04:28Z" + content=""" +Documented both conversions in + +"""]] diff --git a/doc/tips/largefiles.mdwn b/doc/tips/largefiles.mdwn index ae81e54ef9..b0c37c7d1e 100644 --- a/doc/tips/largefiles.mdwn +++ b/doc/tips/largefiles.mdwn @@ -108,3 +108,34 @@ be stored in the annex, you can temporarily override the configuration like this: git annex add -c annex.largefiles=anything smallfile + +## converting git to annexed + +When you have a file that is currently stored in git, and you want to +convert that to be stored in the annex, here's how to accomplish that: + + git rm --cached file + git annex add -c annex.largefiles=anything file + git commit file + +This first removes the file from git's index cache, and then adds it back +using git-annex. You can modify the file before the `git-annex add` step, +perhaps replacing it with new larger content that necessitates git-annex. + +## converting annexed to git + +When you have a file that is currently stored in the annex, and you want to +convert that to be stored in git, here's how to accomplish that: + + git annex unlock file + git add file + git commit -n file + +You can modify the file after unlocking it and before adding it to +git. And this is probably a good idea if it was really a big file, +so that you can replace its content with something smaller. + +Notice the `-n` switch when committing the file. This bypasses the +[[git-annex-precommit]] hook. In this situation, that hook sees an unlocked +file and wants to add it back to the annex, so you have to bypass the hook +to get the file committed to git.