0
0
Gitdevops~20 mins

The .git directory structure - Practice Problems & Coding Challenges

Choose your learning style9 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.