Bird
Raised Fist0
Gitdevops~20 mins

The .git directory structure - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Git Internals Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
1:30remaining
Purpose of the 'objects' directory in .git

What is the main purpose of the objects directory inside the .git folder?

AIt contains configuration files for user settings and repository options.
BIt stores all the content of files and commits as compressed data objects.
CIt holds the logs of all commands executed in the repository.
DIt stores temporary files created during merges and rebases.
Attempts:
2 left
💡 Hint

Think about where Git saves the actual data snapshots.

💻 Command Output
intermediate
1:30remaining
Output of 'ls .git/refs/heads/'

Assuming a Git repository has branches named main, feature1, and bugfix, what will be the output of the command ls .git/refs/heads/?

A
main
feature1
bugfix
B
refs
heads
remotes
C
commit
tree
blob
D
config
HEAD
index
Attempts:
2 left
💡 Hint

The refs/heads directory stores branch references.

❓ Troubleshoot
advanced
2:00remaining
Reason for missing HEAD file in .git

You cloned a repository but the .git/HEAD file is missing. What problem will this cause?

AGit will refuse to push changes to the remote repository.
BGit will lose all commit history permanently.
CGit will automatically create a new default branch.
DGit will not know which branch or commit is currently checked out.
Attempts:
2 left
💡 Hint

The HEAD file points to the current branch or commit.

🔀 Workflow
advanced
2:00remaining
Effect of deleting .git/index file

What happens if you delete the .git/index file in a Git repository?

AGit will lose the staging area information, requiring re-adding files before commit.
BGit will delete all commits and reset the repository to initial state.
CGit will stop tracking remote branches until the index is restored.
DGit will automatically recreate the index with all files staged.
Attempts:
2 left
💡 Hint

The index file stores the staging area snapshot.

✅ Best Practice
expert
2:30remaining
Correct way to backup a Git repository including all history

Which method ensures a complete backup of a Git repository including all branches, tags, and history?

ACreate a patch file with <code>git diff</code> and save it.
BCopy only the working directory files without the <code>.git</code> folder.
CCopy the entire <code>.git</code> directory to a backup location.
DRun <code>git archive</code> and save the output as backup.
Attempts:
2 left
💡 Hint

Think about what contains the full repository data and history.

Practice

(1/5)
1. What is the main purpose of the .git directory in a Git project?
easy
A. It stores all the data and history of the Git repository.
B. It contains the source code files of the project.
C. It holds temporary files created by the operating system.
D. It stores user configuration settings unrelated to Git.

Solution

  1. Step 1: Understand the role of .git directory

    The .git directory is created when you initialize a Git repository and it stores all Git-related data.
  2. Step 2: Differentiate from other directories

    Source code files are outside .git, and temporary or unrelated user files are not stored here.
  3. Final Answer:

    It stores all the data and history of the Git repository. -> Option A
  4. Quick Check:

    .git = Git data storage [OK]
Hint: Remember: .git holds Git's data, not project files [OK]
Common Mistakes:
  • Confusing .git with project source files
  • Thinking it stores temporary OS files
  • Assuming it holds unrelated user configs
2. Which of the following is a correct folder inside the .git directory?
easy
A. src
B. temp
C. bin
D. objects

Solution

  1. Step 1: Recall standard .git folders

    The .git directory contains folders like objects, refs, and hooks.
  2. Step 2: Identify the correct folder

    Among the options, only objects is a valid folder inside .git.
  3. Final Answer:

    objects -> Option D
  4. Quick Check:

    objects folder exists in .git [OK]
Hint: Look for Git-specific folders like objects [OK]
Common Mistakes:
  • Choosing project folders like src
  • Selecting unrelated folders like bin or temp
3. If you look inside the .git/refs/heads folder, what will you typically find?
medium
A. Configuration settings for Git hooks
B. Binary objects of the project files
C. Files representing branches in the repository
D. Temporary files created during commits

Solution

  1. Step 1: Understand refs/heads purpose

    The refs/heads folder stores files named after branches, each containing the commit hash of the branch tip.
  2. Step 2: Differentiate from other folders

    Binary objects are in objects, hooks configs are in hooks, and temporary files are not stored here.
  3. Final Answer:

    Files representing branches in the repository -> Option C
  4. Quick Check:

    refs/heads = branch pointers [OK]
Hint: Remember: refs/heads holds branch names [OK]
Common Mistakes:
  • Confusing branch refs with object storage
  • Thinking hooks configs are here
  • Assuming temporary files are stored here
4. You accidentally deleted the .git/HEAD file. What problem will this cause?
medium
A. Your project files will be deleted.
B. Git will lose track of the current branch or commit.
C. Git will stop tracking remote repositories.
D. Nothing will happen; Git recreates it automatically.

Solution

  1. Step 1: Understand the role of HEAD file

    The HEAD file points to the current branch or commit checked out in the working directory.
  2. Step 2: Consequence of deleting HEAD

    Without HEAD, Git cannot know which branch or commit is active, causing errors in commands.
  3. Final Answer:

    Git will lose track of the current branch or commit. -> Option B
  4. Quick Check:

    HEAD tracks current branch [OK]
Hint: HEAD file = current branch pointer; deleting it breaks Git [OK]
Common Mistakes:
  • Thinking project files get deleted
  • Assuming remote tracking is affected
  • Believing Git auto-recreates HEAD always
5. You want to manually inspect the commit history by reading files inside the .git directory. Which folder should you explore to find the actual commit objects?
hard
A. objects
B. hooks
C. refs
D. logs

Solution

  1. Step 1: Identify where commit data is stored

    The objects folder stores all Git objects including commits, trees, and blobs in compressed form.
  2. Step 2: Differentiate from other folders

    refs holds pointers to commits, hooks contains scripts, and logs track changes to refs.
  3. Final Answer:

    objects -> Option A
  4. Quick Check:

    Commit data = objects folder [OK]
Hint: Commit objects live in objects folder inside .git [OK]
Common Mistakes:
  • Confusing refs with actual commit data
  • Looking in hooks or logs for commits
  • Assuming commit data is in project files
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard