2. Which of the following is the correct syntax to initialize a Git repository in the current directory?
easy
A. git init
B. git start
C. git create
D. git new
Solution
Step 1: Recall the Git command to start a repository
The correct command to initialize a Git repository is git init.
Step 2: Verify other options
Commands like git start, git create, and git new do not exist in Git.
Final Answer:
git init -> Option A
Quick Check:
Initialize repo command = git init = A [OK]
Hint: Use 'git init' exactly to start a repo [OK]
Common Mistakes:
Typing git start instead of git init
Using git create or git new which are invalid
Adding extra words after git init
3. After running git init in an empty folder, what will be the output of ls -a?
medium
A. . .. .gitignore
B. . ..
C. . .. .git .gitignore
D. . .. .git
Solution
Step 1: Understand what git init creates
Running git init creates a hidden .git folder inside the current directory.
Step 2: List all files including hidden ones
The command ls -a shows all files including hidden ones like ., .., and .git. Since the folder is empty except for .git, only these appear.
Final Answer:
. .. .git -> Option D
Quick Check:
git init creates .git folder only = B [OK]
Hint: ls -a shows .git folder after git init [OK]
Common Mistakes:
Expecting .gitignore to appear automatically
Not including hidden files in listing
Confusing .git with other files
4. You ran git init but the .git folder is missing. What is the most likely reason?
medium
A. You ran git init but your folder is already a Git repository.
B. You forgot to install Git on your system.
C. You ran git init inside a folder without write permission.
D. You ran git init with a typo like git initt.
Solution
Step 1: Check permissions for creating .git folder
If the folder does not allow writing, git init cannot create the hidden .git directory.
Step 2: Evaluate other options
If Git was not installed, the command would fail with an error. A typo would cause a command not found error. If the folder was already a Git repo, .git would exist.
Final Answer:
You ran git init inside a folder without write permission. -> Option C
Quick Check:
Missing .git usually means no write permission = D [OK]
Hint: Check folder write permission if .git missing after init [OK]
Common Mistakes:
Assuming Git is not installed without checking error
Ignoring typos in command
Thinking .git disappears if repo exists
5. You want to start tracking an existing project folder with Git. Which sequence of commands correctly initializes the repository and adds all files for the first commit?