1

For a university project, we are using a git repository that was set up by the chair giving the lecture. Once a day their server pulls the latest version of our project and runs secret evaluation tests. Therefore we need to guarantee that the files in our repo can be compiled by the server.

Since we used flex to generate code for one of the tasks we had to accomplish, we need to guarantee that the file was generated by the correct flex-version. (Otherwise, the server can't compile the generated file.)
But my system doesn't support the flex-version of their server. So I do need to generate another version of the file to compile everything on my system. When I'm finished with coding my usual routine at the moment is:

git add --all
git reset generated-file1.c
git reset generated-file2.c
... (commit and push)

Since this was getting on my nerves I've already created a custom command that does this for me. However, I wanted to ask if there is something similar to a .gitignore to "lock" a specific version (that will compile on the server) of our generated files. So anyone on our team will only need to use git add -all in order to add everything except the generated files.

Edit: Thanks to phd's suggestion here I came a little bit closer to what I want. What's still missing for me is the part:

... anyone on our team will only need to to use git add -all...

By using git update-index --skip-worktree generated-file*.c I will only fix this for my system. What I was looking for is a one time change in our repo that affects all systems. (The other members have the same problem as well.)

I know that they could copy and paste the same thing into their terminal, but I wanted to know if there is a more elegant way to do this (similar to the .gitignore), where I can list the files and they will be ignored on every system.

Cheers,
Pascal

plauer
  • 175
  • 1
  • 12
  • Possible duplicate of [Ignore changes to a tracked file](https://stackoverflow.com/questions/32251037/ignore-changes-to-a-tracked-file) – phd Dec 02 '18 at 12:38
  • https://stackoverflow.com/search?q=%5Bgit%5D+ignore+changes+tracked+files – phd Dec 02 '18 at 12:38
  • The answer to "Can I apply the skip-worktree command automatically on every system the repo is cloned on", is unfortunately no. – Lasse V. Karlsen Dec 02 '18 at 13:14
  • @LasseVågsætherKarlsen the question is rather if there exists some work around that does basically the same as "applying the skip-worktree command automatically on every system the repo is cloned on". – plauer Dec 02 '18 at 15:24

1 Answers1

0

This is not how you are supposed to use git. Generally, what you do is you don't check in any generated files in the first place - you just add the generated files or the patterns for the generated files to .gitignore. You should have some kind of Makefile or build script that does all the necessary generation automatically.

Robin Green
  • 32,079
  • 16
  • 104
  • 187
  • This is not possible in my case. The `Makefile` is provided by the chair and will be overwritten before execution on the server side. I am aware that this is the usual way to go but it's not possible in my case. – plauer Dec 02 '18 at 18:31