The problem I'm facing is this:
The application in C has an option where the application compilation date is displayed. To prevent the developer from generating the application with a date before the current day, we avoid using the DATE pre-processing command in any file because the rebuild does not always occur, files that have already been compiled are not recompiled.
So we include in the pre-build script a script that simply creates a file with a current date stamp at a value of #define. This file is generated whenever there is a new build.
example of the content of the generated file (data_compilacao.h):
#define DATA_COMPILACAO "20/02/19"
If the day changes, #define is changed. Otherwise, the file remains unchanged except for the file timestamp.
When I run git status in this scenario without changing the #define value, the file has no real changes – just a timestamp update of the file.
There is a possibility to include the file in .gitignore but I would like to know if there is another way to configure Git to ignore file timestamp changes.
Is there a way to configure git for this? How could I handle this situation?
Thank you for your help.
GIT does not consider different timestamps as file change. What he might consider different is:
- different end of line on different systems ;
- changed permissions on the file;
- any other characters not normally seen in editors;
The first item is underlined as it is usually the culprit in most cases. On a Windows system,
CRLF and *nix
LF . More information about these differences in the Wikipedia article " Newline " .
Many Windows editors either automatically switch
CRLF or add both. So if the code passes from system to system, those problems you're having begin.
You must be in an environment with multiple OS types being used. Therefore, perform the steps below to fix line skipping problems:
1 – On Windows , run:
git config --global core.autocrlf true
2 – On Linux or Mac , run:
git config --global core.autocrlf input
Suggested reading : " Formatting and Whitespace ", in the " core.autocrlf " section. But the content is in English.