0

I need to make sure that a certain folder is excluded for all developers when submitting a code change.

.gitignore won't help as these are files that are already tracked in the repository.

Tried this but .git/info/exclude also couldn't solve the issue.
Tried this but git update-index --assume-unchanged [<file> ...] also failed.
Then I came across this but alas even --skip-worktree failed.

In my build process certain files get added to a folder that is tracked in the repository. But I don't need to submit these files to the repo and also I can't remove these files from the repo as they break the build if done so.
I run git update-index --skip-worktree SDK/ before the build starts.
I also get the ouput on the terminal as Ignoring path SDK/
But after I build and my build modifies some files over in the SDK Folder, around 200 odd files that I modified show up in git status.

Is there any way I can stop it from showing up in git status.
The only workaround I've found so far is to use git checkouot SDK/ after I build to remove these files from being shown in the changed files list.

ShdwKnght333
  • 300
  • 4
  • 23
  • 2
    In general, a file should be viewed as either completely in Git, or completely out of Git. Don't do something half-baked. If that folder doesn't belong there, then `git -rm --cached` it. – Tim Biegeleisen Jan 07 '19 at 05:09
  • I can't do that. We need that folder to exist for our build, but it gets updated when we build it. We don't mind checking it in, but just that it's a nuisance to go through the commit list seeing hundred's of files there. – ShdwKnght333 Jan 07 '19 at 05:23
  • 4
    `but it gets updated when we build it` ... build artifacts should generally not be versioned in Git. I know that it sometimes has to happen, e.g. in certain .NET applications, but you should set out to avoid this if you can, for the reason you are seeing now. – Tim Biegeleisen Jan 07 '19 at 05:24

1 Answers1

0

You could set up a pre-commit hook to check if your file has been staged and let it fail in case it has.

The file will still show up in git status, but your developers will not be able to commit any changes to it.

Turysaz
  • 80
  • 1
  • 7
  • This would work, but the main reason I'm asking this is to remove them from `git status` as I don't want the developers seeing 200 files there, when they might have done a small change in a single file. – ShdwKnght333 Jan 07 '19 at 08:05
  • Hm.. I see. But then on the other hand, if these files are needed for the build only and if they can be seen as "build artifacts", then probably removing them automatically as a build event is not only a "workaround", as you called it, but the best way to go. You could also do it the other way around: add the files to the .gitignore file and automatically copy them from another path within your repository at the beginning of the build. – Turysaz Jan 07 '19 at 12:25