Delphi RES files and Git Delphi RES files and Git git git

Delphi RES files and Git


Welcome to the club. The application .res file in Delphi is a pain in the lower back for everybody using source control. You want to use auto-inc-buildnumber but it messes up your scource control.What I have done is

  • split the icon and the version resources like this:

    {$R *_icon.res}

    {$R *._version.res}

  • disable auto inc of the buildnumber

  • add a pre-build event to the project that

    • increments the build number in a .ini file corresponding the project
    • generates a .rc file with the version info from the .ini file
    • compiles a .res file from the .rc file
  • add the *_icon.res file to source control, it never changes so this is safe

  • add the .ini file with the version info to source control, it is a text file so it is easy to diff

The tool I have written for generating the version .res file is free software, available here and also from OSDN


I keep my project RES files in git (those that match the name of the dpr).

I believe the only reason the project RES file would change every time you build is if you have increment build number set, which to me either means you need to keep the res in source control or you don't care about the build number so you should turn off that option.

I do also have RES files that I build from RC, which change every compile, so I have a gitignore for *.res and I then add git add -f project.res for the project RES files


By definition, RES files are compiled RC files. So ideally you should ignore all RES files and commit only RC changes. If it happened somehow that you don't have an RC source for some particular RES file, then add only this "orphan" RES file to git - such files shouldn't change from build to build (cause there is no RC file to generate them from). If for some strange reasons (Delphi, huh) such RES files do change, then you are doomed.

Bottom line: RES files are compilation targets - no different from other binaries (obj,exe,etc)