Re: RFH: Commiting a removed file by name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Martin Koegler, Sun, Sep 09, 2007 19:33:24 +0200:
> If you don't want to commit all changes at once,
> it is possible to specify a list of file names at
> commit time.
> 
> This works, except you want to remove a file:
> $ git rm -f z4
> rm 'z4'
> $ git commit z4
> error: pathspec 'z4' did not match any file(s) known to git.
> Did you forget to 'git add'?
> $ git --version
> git version 1.5.3.rc7.849.g2f5f
> 
> Is there an easy solution to commit a removed file,
> when you have other changes in the index?

No easy solution, not with removing a file. You better be careful.

There are hard ways if you insist on doing this all the time:

 $ ( export GIT_INDEX_FILE=.git/tmp-index;
     git read-tree HEAD
     git update-index --force-remove -- your-files...
     git commit-tree -p HEAD $(git write-tree) < commit-message)

It is incomplete. And you better not do this anyway, just be careful
about removing.

The problem is that the index and a working tree with a removed file
are actually _without_ something. There is no special fact to commit,
like there is when something changed or added.

P.S. Alternatively, git-commit can be extended. It has all the
information needed to create the fact (the tree pointed by HEAD and
the name(s) of the file to remove from the tree). But I afraid it will
break someones workflow unless guarded by a new flag:

    $ git commit --force-remove -- file

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux