NAME
git-annex unannex - undo accidental add command
SYNOPSIS
git annex unannex [path ...]
DESCRIPTION
Use this to undo an accidental git annex add
command. It puts the
file back how it was before the add.
Note that for safety, the content of the file remains in the annex,
until you use git annex unused
and git annex dropunused
.
This is not the command you should use if you intentionally added a
file some time ago, and don't want its contents any more. In that
case you should use git annex drop
instead, and you can also
git rm
the file.
OPTIONS
--fast
Normally this does a slow copy of the file. In
--fast
mode, it instead makes a hard link from the file to the content in the annex. But use --fast mode with caution, because editing the file will change the content in the annex.file matching options
The git-annex-matching-options(1) can be used to specify files to unannex.
SEE ALSO
git-annex(1)
AUTHOR
Joey Hess id@joeyh.name
Warning: Automatically converted into a man page by mdwn2man. Edit with care.
Hello and thank you for git-annex.
Context
Every newbie needs to understand what steps are possible and what to do when a wrong step was made.
The wording "undo accidental add command" suggested (to me at least) that it was intended to be issued just right after the accidental add command, before any commit.
Steps to reproduce
Right after
git annex add path
, dogit annex unannex path
.Expected behavior
git annex unannex path
would undo the add.More precisely, it would walk the path given, find any symlink pointing to annexed data and not committed yet, and replace it with a plain file with the linked content, honoring
--fast
option if given.Observed behavior
If user follows this path, there will be two unnecessary commits: an add commit and an unannex commit.
There may be reasons to prefer not to introduce those commits. Granted, git allows to adjust history after the fact. Is there a simpler solution?
Question, summarized
Is there a command to just revert a "add", without introducing any commit?
Details
Full test log below:
``` { cd /tmp/ ; mkdir testga ; cd testga ; git init ; git annex init ; echo "test" > test ; git annex add test ; git annex unannex test }
Initialized empty Git repository in /tmp/testga/.git/ init ok (recording state in git...) add test ok (recording state in git...) git-annex: Cannot proceed with uncommitted changes staged in the index. Recommend you: git commit ```
Thank you for any hint.
The behavior your comment describes is only the case with v5 repoitories in indirect mode. With v5 direct mode repositories and with the newer v6 repository format,
git annex unannex
is able to safely handle files that have been added and not committed yet.I was puzzled, believing that recent versions used v6 repository format.
Indeed, all my repositories have been created with 6.20161011-g3135d35 with default options (indirect mode).
git-annex version: 6.20161011-g3135d35 build flags: Assistant Webapp Pairing Testsuite S3(multipartupload)(storageclasses) WebDAV Inotify DBus DesktopNotify XMPP ConcurrentOutput TorrentParser MagicMime Feeds Quvi key/value backends: SHA256E SHA256 SHA512E SHA512 SHA224E SHA224 SHA384E SHA384 SHA3_256E SHA3_256 SHA3_512E SHA3_512 SHA3_224E SHA3_224 SHA3_384E SHA3_384 SKEIN256E SKEIN256 SKEIN512E SKEIN512 SHA1E SHA1 MD5E MD5 WORM URL remote types: git gcrypt S3 bup directory rsync web bittorrent webdav tahoe glacier ddar hook external local repository version: 5 supported repository versions: 3 5 6 upgrade supported from repository versions: 0 1 2 3 4 5 operating system: linux x86_64
I understand now that v6 is still experimental and not enabled by default ( ref http://git-annex.branchable.com/devblog/day_421__lost_in_the_trees/ ).