0
0
Gitdevops~10 mins

Creating a repository with git init - Visual Walkthrough

Choose your learning style9 modes available
Process Flow - Creating a repository with git init
Open terminal
Navigate to folder
Run 'git init'
Git creates .git folder
Folder becomes a git repository
Ready to track files
This flow shows how running 'git init' in a folder creates a hidden .git directory, turning it into a git repository ready to track changes.
Execution Sample
Git
mkdir myproject
cd myproject
git init
Creates a folder, enters it, and initializes a new git repository inside.
Process Table
StepCommandActionResult
1mkdir myprojectCreate folder named 'myproject'Folder 'myproject' created
2cd myprojectChange directory to 'myproject'Current directory is 'myproject'
3git initInitialize git repositoryInitialized empty Git repository in /path/to/myproject/.git/
💡 After 'git init', the folder is now a git repository with a .git directory
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3
Current DirectoryUser home or whereverUser home or wherevermyprojectmyproject
.git folderDoes not existDoes not existDoes not existExists inside 'myproject'
Key Moments - 2 Insights
Why do we not see the .git folder after running 'git init'?
The .git folder is hidden by default in most systems. You can see it by running 'ls -a' in the terminal. This is shown in step 3 where git creates the .git directory.
Does 'git init' add any files to the repository automatically?
No, 'git init' only creates the .git folder to track changes. You still need to add files manually. This is why after step 3, the repository is empty but ready.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, what is the result of running 'git init'?
ACreates a new folder named .git
BDeletes all files in the folder
CInitializes an empty Git repository with a .git folder
DCommits all files automatically
💡 Hint
Check the 'Result' column in step 3 of the execution table
According to the variable tracker, when does the current directory change to 'myproject'?
AAfter step 2
BAfter step 1
CAfter step 3
DIt never changes
💡 Hint
Look at the 'Current Directory' row in the variable tracker after each step
If you run 'git init' twice in the same folder, what happens according to the flow?
AIt overwrites the existing .git folder
BIt does nothing and keeps the existing repository
CIt creates two .git folders
DIt deletes the folder
💡 Hint
Git init is safe to run multiple times; it reinitializes without overwriting the .git folder or losing data
Concept Snapshot
git init
- Run inside a folder to create a new git repository
- Creates a hidden .git directory to track changes
- Does not add or commit files automatically
- Folder becomes ready for git commands like add, commit
- Use 'ls -a' to see the .git folder
Full Transcript
To create a git repository, first open your terminal and navigate to the folder where you want the repository. Run 'git init' there. This command creates a hidden folder named .git that stores all git data. After this, your folder is a git repository ready to track files. The .git folder is hidden, so use 'ls -a' to see it. Running 'git init' does not add any files automatically; you must add files manually. If you run 'git init' again in the same folder, it safely reinitializes the existing repository without overwriting the .git folder or resetting history.