I am working on an interactive git tutorial that a user learns how to use git by following a series of instructions and operating a real git repository. To prevent the learner from ruining the repository or taking wrong steps (and causing the tutorial cannot be continued), I am thinking of taking snapshots of the state of the repository (refs, index, and HEAD etc.) betweeen every few steps and reset to the last one when something unexpected happens.
As taking snapshots of a repo sounds like doing some sort of version control for the .git
folder to me, I am wondering if it is possible to use any version control tool to do the work?
I have tried to put a git repo inside another git repo, and set the .gitignore of the parent repo to include .git folder of the child, but there is no luck. git status
does not show .git
as untracked directory.
Would be glad to hear any idea that can help me taking snapshots of the .git
folder or tricks to preserve status of a git repo and apply it back later.
edit 1
Tried git add -f
to force add the .git
folder, but git refused to add it and threw an error message.
Fortunately, another really dumb trick works. Renaming .git
to any other name would be good enough to trick git to treat it as a normal folder. It is an acceptable solution to me, but not perfect, though.
That being said, since @ErikMD mentioned that my attempts to preserver git repository state via copying .git
does not seem feasible at first sight, I am wondering if I have overlooked something critical? Would there be any problem to keep snapshots of a git repository by managing .git
with a version control toll?