{"thread":{"id":"44133","subject":".gitignore does not ignore Makefile","startedAt":"2016-09-22T14:19:29Z","lastAt":"2016-09-23T22:29:57Z","messageCount":6,"participants":["Timur Tabi","Kevin Daudt","Junio C Hamano","Jakub Narębski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"302372","messageId":"CAOZdJXWpcSZ+jAoV8HttkaB7Fh=wzWDTCsHy8W-S9xOOBodVFw@mail.gmail.com","threadId":"44133","inReplyTo":null,"subject":".gitignore does not ignore Makefile","fromName":"Timur Tabi","fromEmail":"timur@codeaurora.org","sentAt":"2016-09-22T14:19:22Z","receivedAt":"2016-09-22T14:19:29Z","isPatch":false,"sender":{"key":"timur@codeaurora.org","avatar":null},"body":"I have the following .gitignore file in patch arm/arm64/boot/dts:\n\n*.dtb\nqcom\nqcom.orig\n\nWhen I do a git status, I see this:\n\n    modified:   .gitignore\n    modified:   qcom/Makefile\n\nAll of the other files in arm/arm64/boot/dts/qcom are being ignored,\nas request.  However, the file \"Makefile\" is not being ignored.  Why?\nWhat's so special about \"Makefile\" that git refuses to ignore it?\n\n-- \nQualcomm Innovation Center, Inc.\nThe Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,\na Linux Foundation Collaborative Project.\n"},{"id":"302374","messageId":"20160922154421.GA6641@ikke.info","threadId":"44133","inReplyTo":"CAOZdJXWpcSZ+jAoV8HttkaB7Fh=wzWDTCsHy8W-S9xOOBodVFw@mail.gmail.com","subject":"Re: .gitignore does not ignore Makefile","fromName":"Kevin Daudt","fromEmail":"me@ikke.info","sentAt":"2016-09-22T15:44:21Z","receivedAt":"2016-09-22T15:44:51Z","isPatch":false,"sender":{"key":"me@ikke.info","avatar":"https://avatars.githubusercontent.com/u/135698?v=4"},"body":"On Thu, Sep 22, 2016 at 09:19:22AM -0500, Timur Tabi wrote:\n> I have the following .gitignore file in patch arm/arm64/boot/dts:\n> \n> *.dtb\n> qcom\n> qcom.orig\n> \n> When I do a git status, I see this:\n> \n>     modified:   .gitignore\n>     modified:   qcom/Makefile\n> \n> All of the other files in arm/arm64/boot/dts/qcom are being ignored,\n> as request.  However, the file \"Makefile\" is not being ignored.  Why?\n> What's so special about \"Makefile\" that git refuses to ignore it?\n> \n\nThere is nothing special about the Makefile, except that it's tracked.\nGit never ignores tracked files (almost a paradox).\n\nYou can untrack the file by doing git rm --cached <file>, which new\ncommits won't have this file.\n\nIf your goal is to ignore local changes to a tracked file, then the\nadvise is to reconsider your plan. \n\nOften people advise tricks like `git update-index --assume-unchanges\n<file>`, but this does not work as expected. It's merely a promise to\ngit that this file does not change (and hence, git will not check if\nthis file has changed when doing git status), but command that try to\nchange this file will abort saying that the file has changed.\n\nHope this helps,\n\nKevin.\n\n"},{"id":"302383","messageId":"xmqqy42j4wp9.fsf@gitster.mtv.corp.google.com","threadId":"44133","inReplyTo":"20160922154421.GA6641@ikke.info","subject":"Re: .gitignore does not ignore Makefile","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-09-22T18:26:58Z","receivedAt":"2016-09-22T18:27:35Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Kevin Daudt <me@ikke.info> writes:\n\n> Often people advise tricks like `git update-index --assume-unchanges\n> <file>`, but this does not work as expected. It's merely a promise to\n> git that this file does not change (and hence, git will not check if\n> this file has changed when doing git status), but command that try to\n> change this file will abort saying that the file has changed.\n\nIt actually is even worse.  As the user promised Git that the <file>\nwill not be modified and will be kept the same as the version in the\nindex, Git reserves the right to _overwrite_ it with the version in\nthe index anytime when it is convenient to do so, removing whatever\nlocal change the user had despite the promise to Git.  The \"abort\nsaying that the file has changed\" is merely various codepaths in the\ncurrent implementation trying to be extra nice.\n\n\n\n"},{"id":"302387","messageId":"57E4267B.1050507@codeaurora.org","threadId":"44133","inReplyTo":"xmqqy42j4wp9.fsf@gitster.mtv.corp.google.com","subject":"Re: .gitignore does not ignore Makefile","fromName":"Timur Tabi","fromEmail":"timur@codeaurora.org","sentAt":"2016-09-22T18:44:11Z","receivedAt":"2016-09-22T18:44:23Z","isPatch":false,"sender":{"key":"timur@codeaurora.org","avatar":null},"body":"Junio C Hamano wrote:\n> It actually is even worse.  As the user promised Git that the <file>\n> will not be modified and will be kept the same as the version in the\n> index, Git reserves the right to_overwrite_  it with the version in\n> the index anytime when it is convenient to do so, removing whatever\n> local change the user had despite the promise to Git.  The \"abort\n> saying that the file has changed\" is merely various codepaths in the\n> current implementation trying to be extra nice.\n\nSo .gitignore only ignores new files, not modified ones?  That seems \nodd, but I guess that's the way it's always been and I just haven't \nnoticed until now.\n\n-- \nQualcomm Datacenter Technologies, Inc. as an affiliate of Qualcomm\nTechnologies, Inc.  Qualcomm Technologies, Inc. is a member of the\nCode Aurora Forum, a Linux Foundation Collaborative Project.\n"},{"id":"302398","messageId":"xmqqtwd74ue8.fsf@gitster.mtv.corp.google.com","threadId":"44133","inReplyTo":"57E4267B.1050507@codeaurora.org","subject":"Re: .gitignore does not ignore Makefile","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-09-22T19:16:47Z","receivedAt":"2016-09-22T19:17:42Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Timur Tabi <timur@codeaurora.org> writes:\n\n> So .gitignore only ignores new files, not modified ones?\n\nIt is determines if an untracked file should be considered by \"git\nadd\" to add it or ignore it.\n"},{"id":"302468","messageId":"d98bd20f-870a-71a0-fda2-aabe71a5f981@gmail.com","threadId":"44133","inReplyTo":"xmqqy42j4wp9.fsf@gitster.mtv.corp.google.com","subject":"Re: .gitignore does not ignore Makefile","fromName":"Jakub Narębski","fromEmail":"jnareb@gmail.com","sentAt":"2016-09-23T22:29:29Z","receivedAt":"2016-09-23T22:29:57Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"W dniu 22.09.2016 o 20:26, Junio C Hamano napisał:\n> Kevin Daudt <me@ikke.info> writes:\n> \n>> Often people advise tricks like `git update-index --assume-unchanges\n>> <file>`, but this does not work as expected. It's merely a promise to\n>> git that this file does not change (and hence, git will not check if\n>> this file has changed when doing git status), but command that try to\n>> change this file will abort saying that the file has changed.\n> \n> It actually is even worse.  As the user promised Git that the <file>\n> will not be modified and will be kept the same as the version in the\n> index, Git reserves the right to _overwrite_ it with the version in\n> the index anytime when it is convenient to do so, removing whatever\n> local change the user had despite the promise to Git.  The \"abort\n> saying that the file has changed\" is merely various codepaths in the\n> current implementation trying to be extra nice.\n \nThere is a trick that works almost as 'ignore changes' for tracked\nfiles, namely `git update-index --skip-worktree <file>`.  From the\ndocumentation:\n\n  Skip-worktree bit\n  ~~~~~~~~~~~~~~~~~\n\n  Skip-worktree bit can be defined in one (long) sentence: When\n  reading an entry, if it is marked as skip-worktree, then Git\n  pretends its working directory version is up to date and read\n  the index version instead.\n\n  [...] Writing is not affected by this bit, content safety is still\n  first priority. [...]\n\nIt works quite well; the only problem is that `git stash` would\nnot stash away your changes, and you would need to unmark such\nfile before saving a stash.\n\n\nWith --assume-unchanged used for ignoring changes to tracked files,\nyou can quite easily lose your work because you are lying to Git.\n\n\nNote also that in Git classic \"ignored\" implies unimportant.\n-- \nJakub Narębski\n\n"}]}