From: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
To: list@phuk.ath.cx
Cc: git@vger.kernel.org
Subject: Re: git rm --cached and pull semantics
Date: Sun, 17 Jan 2010 12:42:03 +0100 [thread overview]
Message-ID: <vpq1vhpufec.fsf@bauges.imag.fr> (raw)
In-Reply-To: <4B51EE39.3010401@phuk.ath.cx> (list@phuk.ath.cx's message of "Sat\, 16 Jan 2010 17\:50\:01 +0100")
list@phuk.ath.cx writes:
> Hello everyone,
>
> I'm trying to manage and distribute a subset of /etc with git.
> Therefore, I have * in .gitignore and use git add -f to add files. Now
> sometimes I want to un-track a file that has been in previous commits,
> but naturally I don't want the file deleted. I just want git to ignore
> it again. As I read it, the way to do that is "git rm --cached $file".
> On the local working tree, that works as expected, but when some remote
> machine pulls a subsequent commit, it deletes the file from its working
> tree. But I just want git to ignore the file again, just as it does in
> the origin repo. How can I do that?
I'd say there's no way, and there will hardly ever be any :-(.
Git is purely snapshot-oriented, which means that when you do a "git
rm --cached", the next commit doesn't say "this file has been
removed", but instead, it says "the file is not here", which can be
interpreted as "the file is not here _anymore_" when comparing the
commit and its ancestor.
But as a result, there's no place to store information about _how_ the
file was removed. So, for the remote machine doing a "git pull", the
merge algorithm just sees that it's not there, and deletes it.
OTOH, after "git pull", it's rather simple to do something like
git show HEAD@{1}:your-file.txt > your-file.txt
to restore it as an untracked file. Maybe it's possible to automate
this in a script, but I have no idea how.
--
Matthieu Moy
http://www-verimag.imag.fr/~moy/
next prev parent reply other threads:[~2010-01-17 11:42 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-01-16 16:50 git rm --cached and pull semantics list
2010-01-17 11:42 ` Matthieu Moy [this message]
2010-01-17 22:50 ` list
2010-01-18 0:06 ` Randal L. Schwartz
2010-01-18 2:31 ` list
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=vpq1vhpufec.fsf@bauges.imag.fr \
--to=matthieu.moy@grenoble-inp.fr \
--cc=git@vger.kernel.org \
--cc=list@phuk.ath.cx \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).