git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* .gitignore does not ignore Makefile
@ 2016-09-22 14:19 Timur Tabi
  2016-09-22 15:44 ` Kevin Daudt
  0 siblings, 1 reply; 6+ messages in thread
From: Timur Tabi @ 2016-09-22 14:19 UTC (permalink / raw)
  To: git

I have the following .gitignore file in patch arm/arm64/boot/dts:

*.dtb
qcom
qcom.orig

When I do a git status, I see this:

    modified:   .gitignore
    modified:   qcom/Makefile

All of the other files in arm/arm64/boot/dts/qcom are being ignored,
as request.  However, the file "Makefile" is not being ignored.  Why?
What's so special about "Makefile" that git refuses to ignore it?

-- 
Qualcomm Innovation Center, Inc.
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: .gitignore does not ignore Makefile
  2016-09-22 14:19 .gitignore does not ignore Makefile Timur Tabi
@ 2016-09-22 15:44 ` Kevin Daudt
  2016-09-22 18:26   ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Daudt @ 2016-09-22 15:44 UTC (permalink / raw)
  To: Timur Tabi; +Cc: git

On Thu, Sep 22, 2016 at 09:19:22AM -0500, Timur Tabi wrote:
> I have the following .gitignore file in patch arm/arm64/boot/dts:
> 
> *.dtb
> qcom
> qcom.orig
> 
> When I do a git status, I see this:
> 
>     modified:   .gitignore
>     modified:   qcom/Makefile
> 
> All of the other files in arm/arm64/boot/dts/qcom are being ignored,
> as request.  However, the file "Makefile" is not being ignored.  Why?
> What's so special about "Makefile" that git refuses to ignore it?
> 

There is nothing special about the Makefile, except that it's tracked.
Git never ignores tracked files (almost a paradox).

You can untrack the file by doing git rm --cached <file>, which new
commits won't have this file.

If your goal is to ignore local changes to a tracked file, then the
advise is to reconsider your plan. 

Often people advise tricks like `git update-index --assume-unchanges
<file>`, but this does not work as expected. It's merely a promise to
git that this file does not change (and hence, git will not check if
this file has changed when doing git status), but command that try to
change this file will abort saying that the file has changed.

Hope this helps,

Kevin.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: .gitignore does not ignore Makefile
  2016-09-22 15:44 ` Kevin Daudt
@ 2016-09-22 18:26   ` Junio C Hamano
  2016-09-22 18:44     ` Timur Tabi
  2016-09-23 22:29     ` Jakub Narębski
  0 siblings, 2 replies; 6+ messages in thread
From: Junio C Hamano @ 2016-09-22 18:26 UTC (permalink / raw)
  To: Kevin Daudt; +Cc: Timur Tabi, git

Kevin Daudt <me@ikke.info> writes:

> Often people advise tricks like `git update-index --assume-unchanges
> <file>`, but this does not work as expected. It's merely a promise to
> git that this file does not change (and hence, git will not check if
> this file has changed when doing git status), but command that try to
> change this file will abort saying that the file has changed.

It actually is even worse.  As the user promised Git that the <file>
will not be modified and will be kept the same as the version in the
index, Git reserves the right to _overwrite_ it with the version in
the index anytime when it is convenient to do so, removing whatever
local change the user had despite the promise to Git.  The "abort
saying that the file has changed" is merely various codepaths in the
current implementation trying to be extra nice.




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: .gitignore does not ignore Makefile
  2016-09-22 18:26   ` Junio C Hamano
@ 2016-09-22 18:44     ` Timur Tabi
  2016-09-22 19:16       ` Junio C Hamano
  2016-09-23 22:29     ` Jakub Narębski
  1 sibling, 1 reply; 6+ messages in thread
From: Timur Tabi @ 2016-09-22 18:44 UTC (permalink / raw)
  To: Junio C Hamano, Kevin Daudt; +Cc: git

Junio C Hamano wrote:
> It actually is even worse.  As the user promised Git that the <file>
> will not be modified and will be kept the same as the version in the
> index, Git reserves the right to_overwrite_  it with the version in
> the index anytime when it is convenient to do so, removing whatever
> local change the user had despite the promise to Git.  The "abort
> saying that the file has changed" is merely various codepaths in the
> current implementation trying to be extra nice.

So .gitignore only ignores new files, not modified ones?  That seems 
odd, but I guess that's the way it's always been and I just haven't 
noticed until now.

-- 
Qualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm
Technologies, Inc.  Qualcomm Technologies, Inc. is a member of the
Code Aurora Forum, a Linux Foundation Collaborative Project.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: .gitignore does not ignore Makefile
  2016-09-22 18:44     ` Timur Tabi
@ 2016-09-22 19:16       ` Junio C Hamano
  0 siblings, 0 replies; 6+ messages in thread
From: Junio C Hamano @ 2016-09-22 19:16 UTC (permalink / raw)
  To: Timur Tabi; +Cc: Kevin Daudt, git

Timur Tabi <timur@codeaurora.org> writes:

> So .gitignore only ignores new files, not modified ones?

It is determines if an untracked file should be considered by "git
add" to add it or ignore it.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: .gitignore does not ignore Makefile
  2016-09-22 18:26   ` Junio C Hamano
  2016-09-22 18:44     ` Timur Tabi
@ 2016-09-23 22:29     ` Jakub Narębski
  1 sibling, 0 replies; 6+ messages in thread
From: Jakub Narębski @ 2016-09-23 22:29 UTC (permalink / raw)
  To: Junio C Hamano, Kevin Daudt; +Cc: Timur Tabi, git

W dniu 22.09.2016 o 20:26, Junio C Hamano napisał:
> Kevin Daudt <me@ikke.info> writes:
> 
>> Often people advise tricks like `git update-index --assume-unchanges
>> <file>`, but this does not work as expected. It's merely a promise to
>> git that this file does not change (and hence, git will not check if
>> this file has changed when doing git status), but command that try to
>> change this file will abort saying that the file has changed.
> 
> It actually is even worse.  As the user promised Git that the <file>
> will not be modified and will be kept the same as the version in the
> index, Git reserves the right to _overwrite_ it with the version in
> the index anytime when it is convenient to do so, removing whatever
> local change the user had despite the promise to Git.  The "abort
> saying that the file has changed" is merely various codepaths in the
> current implementation trying to be extra nice.
 
There is a trick that works almost as 'ignore changes' for tracked
files, namely `git update-index --skip-worktree <file>`.  From the
documentation:

  Skip-worktree bit
  ~~~~~~~~~~~~~~~~~

  Skip-worktree bit can be defined in one (long) sentence: When
  reading an entry, if it is marked as skip-worktree, then Git
  pretends its working directory version is up to date and read
  the index version instead.

  [...] Writing is not affected by this bit, content safety is still
  first priority. [...]

It works quite well; the only problem is that `git stash` would
not stash away your changes, and you would need to unmark such
file before saving a stash.


With --assume-unchanged used for ignoring changes to tracked files,
you can quite easily lose your work because you are lying to Git.


Note also that in Git classic "ignored" implies unimportant.
-- 
Jakub Narębski


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-09-23 22:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-22 14:19 .gitignore does not ignore Makefile Timur Tabi
2016-09-22 15:44 ` Kevin Daudt
2016-09-22 18:26   ` Junio C Hamano
2016-09-22 18:44     ` Timur Tabi
2016-09-22 19:16       ` Junio C Hamano
2016-09-23 22:29     ` Jakub Narębski

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).