0

Let's say I have a simple C file:

int main(){
  // commented code
  return 0;
}

Can I commit this file with the commented line removed?

Nathaniel Ford
  • 20,545
  • 20
  • 91
  • 102
  • 1
    Are you asking if there is a way for git to scan your files before they are committed, and preprocess the files with a script to remove the comments? – Paul Aug 06 '15 at 21:43
  • possibly related: http://stackoverflow.com/questions/16831536/can-you-change-a-file-content-during-git-commit – Paul Aug 06 '15 at 21:47
  • agree. some kind of precommit hook would be the way to accomplish this although this is a very unusual use of an scm tool. – Mike D Aug 07 '15 at 00:59

3 Answers3

0

GIT is a stupid content tracker

It doesn't ignore any changes to your files even a change in a char or comments to your file

Vamsi Ravi
  • 1,196
  • 8
  • 26
0

I believe you can't. When you do git commit, It will eventually commit all of the content including your comment.

0

You can check clean filters here. You can define your own attribute to ignore the snippet/regex in code

Gaurav Tiwari
  • 362
  • 2
  • 7