Git 2

Build a git repository

1 using “normal” git commands

Please have a look at the following git repository structure:

git objects (from the git book)
  • Write a script which creates a git repository matching the depicted structure. You may use the usual git frontend commands, e.g. starting with git init, git add, git commit etc…
  • Have a look at the resulting git object hashes and compare them with the hashes shown in the figure. Likely not all hashes in your repository will be equal to the ones in the picture. Explain which hashes are or should be equal and which should not and why.

2 manually

  • Write another script, which creates a similar git repository, but do so without using the git command at all. You can choose any programming language of your choice and of course may reuse or extend code snippets from the lecture. You can find further code snippets for details of the git objects in the appendix of this exercise.
  • Check if the repository is accessible using git log.
Tip

You may find that git status shows that your repository is not in a clean state. That’s ok and likely because we didn’t talk in detail about the “index”. You can fix the index of your test (!) repository using git restore --staged . and afterwards the working direcory using git restore ..