{"thread":{"id":"24440","subject":"Automatically exclude hunks from the commit","startedAt":"2010-07-20T03:02:32Z","lastAt":"2010-07-20T09:26:20Z","messageCount":4,"participants":["Joshua Jensen","Joshua Juran","Wincent Colaiuta","Michael J Gruber"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"145834","messageId":"4C4511C8.8090405@workspacewhiz.com","threadId":"24440","inReplyTo":null,"subject":"Automatically exclude hunks from the commit","fromName":"Joshua Jensen","fromEmail":"jjensen@workspacewhiz.com","sentAt":"2010-07-20T03:02:32Z","receivedAt":"2010-07-20T03:02:32Z","isPatch":false,"sender":{"key":"jjensen@workspacewhiz.com","avatar":"https://avatars.githubusercontent.com/u/111687?v=4"},"body":"  I have some files I update frequently where I have some normally \ncommented out debug code purposely uncommented during development.  \nGit's hunk-level staging saves the day.  I can stage everything but the \ndebug code without issue.\n\nThis got me to thinking.  Is there a better way?  Is there a facility in \nGit where I could mark a hunk as 'permanently frozen unstaged'?  \nAnything marked as such would never be staged for commit.  I could rest \nassured I would never accidentally commit my debug code, be it extra \nprintfs or a development server or a password or so on.\n\nThanks for the help.\n\nJosh\n"},{"id":"145842","messageId":"C18AA39F-1ADD-46A8-8A10-25A6B6AF26CB@gmail.com","threadId":"24440","inReplyTo":"4C4511C8.8090405@workspacewhiz.com","subject":"Re: Automatically exclude hunks from the commit","fromName":"Joshua Juran","fromEmail":"jjuran@gmail.com","sentAt":"2010-07-20T05:17:58Z","receivedAt":"2010-07-20T05:17:58Z","isPatch":false,"sender":{"key":"jjuran@gmail.com","avatar":null},"body":"On Jul 19, 2010, at 8:02 PM, Joshua Jensen wrote:\n\n> I have some files I update frequently where I have some normally  \n> commented out debug code purposely uncommented during development.   \n> Git's hunk-level staging saves the day.  I can stage everything but  \n> the debug code without issue.\n>\n> This got me to thinking.  Is there a better way?  Is there a  \n> facility in Git where I could mark a hunk as 'permanently frozen  \n> unstaged'?  Anything marked as such would never be staged for  \n> commit.  I could rest assured I would never accidentally commit my  \n> debug code, be it extra printfs or a development server or a  \n> password or so on.\n\nHow about keeping your debug changes in a separate branch?  I work on  \na branch called 'hack', to which I'll commit pretty much anything.   \nWhen a patch is ready, I cherry-pick it from master and rebase hack  \nonto master.[1]\n\nPasswords which are so sensitive that they can't ever be checked in  \nshould be stored in ignored files or outside the repo entirely.\n\nJosh\n\n[1] It's actually more complicated than that.  I create 'tip' as a  \nmerger of master and my formal topic branches, and hack stays rebased  \non tip.\n"},{"id":"145845","messageId":"51F8E66E-9CDD-466A-8411-38CA8431D8AC@wincent.com","threadId":"24440","inReplyTo":"4C4511C8.8090405@workspacewhiz.com","subject":"Re: Automatically exclude hunks from the commit","fromName":"Wincent Colaiuta","fromEmail":"win@wincent.com","sentAt":"2010-07-20T05:36:16Z","receivedAt":"2010-07-20T05:36:16Z","isPatch":false,"sender":{"key":"greg@hurrell.net","avatar":"https://avatars.githubusercontent.com/u/7074?v=4"},"body":"El 20/07/2010, a las 05:02, Joshua Jensen escribió:\n\n> I have some files I update frequently where I have some normally commented out debug code purposely uncommented during development.  Git's hunk-level staging saves the day.  I can stage everything but the debug code without issue.\n> \n> This got me to thinking.  Is there a better way?  Is there a facility in Git where I could mark a hunk as 'permanently frozen unstaged'?  Anything marked as such would never be staged for commit.  I could rest assured I would never accidentally commit my debug code, be it extra printfs or a development server or a password or so on.\n\nA custom pre-commit hook might be of some use here. You could create one which rejects changes which are obviously debug code.\n\nCheers,\nWincent\n"},{"id":"145848","messageId":"4C456BBC.8010203@drmicha.warpmail.net","threadId":"24440","inReplyTo":"4C4511C8.8090405@workspacewhiz.com","subject":"Re: Automatically exclude hunks from the commit","fromName":"Michael J Gruber","fromEmail":"git@drmicha.warpmail.net","sentAt":"2010-07-20T09:26:20Z","receivedAt":"2010-07-20T09:26:20Z","isPatch":false,"sender":{"key":"git@grubix.eu","avatar":"https://avatars.githubusercontent.com/u/233215?v=4"},"body":"Joshua Jensen venit, vidit, dixit 20.07.2010 05:02:\n>   I have some files I update frequently where I have some normally \n> commented out debug code purposely uncommented during development.  \n> Git's hunk-level staging saves the day.  I can stage everything but the \n> debug code without issue.\n> \n> This got me to thinking.  Is there a better way?  Is there a facility in \n> Git where I could mark a hunk as 'permanently frozen unstaged'?  \n> Anything marked as such would never be staged for commit.  I could rest \n> assured I would never accidentally commit my debug code, be it extra \n> printfs or a development server or a password or so on.\n> \n> Thanks for the help.\n> \n> Josh\n\nIf you don't want to deal with the branch approach suggested by the\nother Joshua you could (ab)use the clean&smudge filters (see \"filter\" in\ngitattributes(5)):\n\nDefine a clean filter such as \"fgrep -v GITIGNORE\" and mark every source\nline which you want to ignore with a comment:\n\nprintf(\"Happy we got this far but I have no clue why\"); // GITIGNORE\n\nYou can do more clever things with awk or sed, of course. \"GITIGNORE\" is\njust some hopefully unused string.\n\nNote that a \"checkout\" would overwrite your debug lines!\n\nCheers,\nMichael\n"}]}