0
0
Gitdevops~20 mins

Creating a repository with git init - Practice Exercises

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Git Init Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
1:30remaining
What is the output of git init in a new directory?
You run git init inside an empty folder. What message does Git show?
Git
git init
Afatal: Not a git repository (or any of the parent directories): .git
BInitialized empty Git repository in /path/to/directory/.git/
CError: Repository already exists
DNothing to commit, working tree clean
Attempts:
2 left
💡 Hint
Think about what Git says when it creates a new repository folder.
🧠 Conceptual
intermediate
1:30remaining
What does git init actually do?
Choose the correct description of what git init does when run in a folder.
ACreates a new hidden .git directory to track changes in the folder
BMerges the current folder with another Git repository
CDeletes all files in the folder and starts fresh
DUploads the folder contents to a remote Git server
Attempts:
2 left
💡 Hint
Think about what Git needs to track changes locally.
Troubleshoot
advanced
2:00remaining
Why does git init fail with 'Permission denied'?
You try to run git init in a folder but get this error:
fatal: could not create work tree dir 'folder': Permission denied
What is the most likely cause?
AThe folder is already a Git repository
BGit is not installed on your system
CYou do not have write permission for the folder
DYou forgot to run <code>git clone</code> first
Attempts:
2 left
💡 Hint
Think about what 'Permission denied' means in file systems.
🔀 Workflow
advanced
2:00remaining
What is the correct sequence to create and start tracking files with Git?
You want to start a new project folder and track files with Git. Which sequence of commands is correct?
Acd project; mkdir project; git init; git commit -m 'first commit'; git add .
Bgit init; mkdir project; cd project; git add .; git commit -m 'first commit'
Cmkdir project; git init; git add .; cd project; git commit -m 'first commit'
Dmkdir project; cd project; git init; git add .; git commit -m 'first commit'
Attempts:
2 left
💡 Hint
You must create and enter the folder before initializing Git there.
Best Practice
expert
2:30remaining
Which practice is best when initializing a Git repository for a new project?
You start a new project and run git init. What should you do next to avoid committing unwanted files?
ACreate a .gitignore file listing files and folders to exclude before adding files
BImmediately commit all files without filtering
CRun <code>git clone</code> to copy files from a remote repo
DDelete all hidden files before committing
Attempts:
2 left
💡 Hint
Think about how to prevent temporary or sensitive files from being tracked.