1. Description of the problem
Suppose I have the following project foo:
Project foo is cloned from a GitHub repository I own, and checked out to the master branch. Subfolders bar and baz contain pure source code. Subfolder tools contains some software that I need to run the project.
From time to time, I delete software in the tools folder to replace them with newer versions. Git keeps the history of everything that ever existed in the tools folder. That is absolutely not necessary.
2. Questions
I've got two questions:
Is it possible to delete the entire history of subfolder tools, without touching the history of bar and baz? The entire history of tools should be wiped out from my local
.git
repo and the remote GitHub repo once I push. When my coworkers pull, their local history of tools should be wiped out as well.Is it possible to - starting from today - make Git stop keeping history for the tools folder? For example: I replace
tool_x_v1.0
withtool_x_v1.1
, commit and push to GitHub. My coworkers pull from GitHub and should receivetool_x_v1.1
. All traces of the oldtool_x_v1.0
should be wiped out from the remote GitHub repo and all local.git
repos.
Note: We also assume thattool_x_v1.1
is perfectly backwards compatible withtool_x_v1.0
.
3. Side effects
Now you may wonder:
What happens when I checkout an old commit - let's say a commit from 5 Nov 2018. The tools subfolder has no history dating back to that moment (its entire history is gone). What will it contain?
Subfolder tools should simply contain the current contents - no matter what old commit you're checking out. I would even go further: no matter what branch you're checking out. The tools folder has no history and is branch-agnostic. As simple as that.
4. Criticism
Some of you will think:
Just don't use Git for this tools subfolder (put it in .gitignore
). Use something else to synchronize this particular subfolder with your coworkers.
That's indeed possible. But anyone who clones the git repo from GitHub will be unhappy when he/she realizes the project doesn't work. He/She will need to download the tools folder from some other source, and possible need to install some third-party software to keep it up-to-date. Very cumbersome, don't you think?
If you disagree - just ignore me and live happily ever after. Please don't go ranting in the comments, telling me how evil I am desecrating the noble Git.