Thread (4 messages) flat view 4 messages, 4 authors, 2016-06-15

Re: Automatically exclude hunks from the commit

From: Michael J Gruber <hidden>
Date: 2016-06-15 22:49:09

Joshua Jensen venit, vidit, dixit 20.07.2010 05:02:
  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.

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.

Thanks for the help.

Josh
If you don't want to deal with the branch approach suggested by the
other Joshua you could (ab)use the clean&smudge filters (see "filter" in
gitattributes(5)):

Define a clean filter such as "fgrep -v GITIGNORE" and mark every source
line which you want to ignore with a comment:

printf("Happy we got this far but I have no clue why"); // GITIGNORE

You can do more clever things with awk or sed, of course. "GITIGNORE" is
just some hopefully unused string.

Note that a "checkout" would overwrite your debug lines!

Cheers,
Michael
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help