From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: "Halde\, Faiz" <fhalde@paypal.com>,
"git\@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: Git issue
Date: Tue, 01 Nov 2016 11:11:34 -0700 [thread overview]
Message-ID: <xmqqy413oysp.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20161101174526.e2tilsriz2fqaru3@sigill.intra.peff.net> (Jeff King's message of "Tue, 1 Nov 2016 13:45:26 -0400")
Jeff King <peff@peff.net> writes:
> On Tue, Nov 01, 2016 at 10:28:57AM +0000, Halde, Faiz wrote:
>
>> I frequently use the following command to ignore changes done in a file
>>
>> git update-index --assume-unchanged somefile
>>
>> Now when I do a pull from my remote branch and say the file 'somefile'
>> was changed locally and in remote, git will abort the merge saying I
>> need to commit my changes of 'somefile'.
>>
>> But isn't the whole point of the above command to ignore the changes
>> within the file?
>
> No. The purpose of --assume-unchanged is to promise git that you will
> not change the file, so that it may skip checking the file contents in
> some cases as an optimization.
That's correct.
The next anticipated question is "then how would I tell Git to
ignore changes done to a file locally by me?", whose short answer is
"You don't", of course.
People may however wonder, if Git can make things more automatic if
the user is willing to tell her intention of what should happen to
"somefile" in the example above when an operation requested cannot
proceed while ignoring the local changes. For example, "ignore my
change and overwrite as needed" could be such an instruction (and it
is obvious what should happen in that case when "git pull" was
done--just clobber it with the version from the other side).
As I do not think of other sensible alternative behaviour, and I do
not think Git should make it easy to lose local changes when the
user is doing things like "pull" [*1*], it leads to the longer
answer to the question, which is again "You don't" ;-).
[Footnote]
*1* Things like "git checkout [<tree>] [--] <path>", "git rm -f" and
"git reset --hard" are ways to explicit request nuking the local
changes, and presence of these commands do not contradict with
"do not make it easy to lose local changes", of course.
next prev parent reply other threads:[~2016-11-01 18:11 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-01 10:28 Git issue Halde, Faiz
2016-11-01 17:45 ` Jeff King
2016-11-01 18:11 ` Junio C Hamano [this message]
2016-11-07 22:34 ` Git issue - ignoring changes to tracked file with assume-unchanged Jakub Narębski
2016-11-01 20:50 ` Git issue Philip Oakley
2016-11-01 21:03 ` Jeff King
2016-11-01 21:23 ` Junio C Hamano
2016-11-04 4:52 ` Jacob Keller
2016-11-01 21:04 ` [PATCH] doc: update-index --assume-unchanged Philip Oakley
-- strict thread matches above, loose matches on Subject: below --
2015-07-01 13:37 git issue Toralf Förster
2015-07-01 14:21 ` Dave Jones
2015-07-01 15:11 ` Toralf Förster
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=xmqqy413oysp.fsf@gitster.mtv.corp.google.com \
--to=gitster@pobox.com \
--cc=fhalde@paypal.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.