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.
Also the git-annex-common-options(1) can be used.
SEE ALSO
git-annex(1)
AUTHOR
Joey Hess id@joeyh.name
Warning: Automatically converted into a man page by mdwn2man. Edit with care.
@datamanager the
git-annex unannex
command can't rewrite git history, it just stops further tracking of an annexed file by git. Any way you would usually scrub an unwanted commit out of git's history can be used with git-annex; scrubbing mentioned of hashes out of the git-annex branch's history gets more involved.Once you have run
git-annex unannex
on a file, it's not annexed, so commands likegit-annex whereis
will not have anything to say about it.Essentially, I want to tell git-annex to forget about my file; remove it from the annex, and put the original file back where it was in my local filesystem.
I made the mistake of adding a list of files accidentally, and then panicked. I even ran git-annex-sync, so there's now a commit on the git-annex branch with my accidentally added files. I thought that maybe I could just revert that commit and all would be well, but I thought I'd seek some assistance before doing that.
I haven't copied the files to any other remotes as yet, but git-annex-whereis returns nothing when I give it one of the paths I added by mistake, so those files seem to be in some kind of limbo, where they're in the annex, but it doesn't know about them. I am not sure what I broke along the way.
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).
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/ ).
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.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:
Thank you for any hint.