🔧 𝐆𝐢𝐭 𝐢𝐧𝐢𝐭
Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to
𝐠𝐢𝐭 𝐢𝐧𝐢𝐭 is a Git command used to initialize a new Git repository. When you run this command in a directory, it sets up all the necessary files and data structures required for version control using Git. This essentially marks the beginning of a new Git repository in that directory.
Here’s what 𝐠𝐢𝐭 𝐢𝐧𝐢𝐭does:
• 𝐂𝐫𝐞𝐚𝐭𝐞𝐬 𝐭𝐡𝐞.𝐠𝐢𝐭
𝐃𝐢𝐫𝐞𝐜𝐭𝐨𝐫𝐲
The primary action of 𝐠𝐢𝐭 𝐢𝐧𝐢𝐭 is to create a new subdirectory named .git in the root of the working directory. This directory contains all the information necessary for version control, including configuration files, object database, references, and other Git-related data.
• 𝐒𝐞𝐭𝐬 𝐔𝐩 𝐈𝐧𝐢𝐭𝐢𝐚𝐥 𝐂𝐨𝐧𝐟𝐢𝐠𝐮𝐫𝐚𝐭𝐢𝐨𝐧
Git configuration files are created within the .𝐠𝐢𝐭 directory, including 𝐜𝐨𝐧𝐟𝐢𝐠 and other settings files. These files store configuration options for the repository.
• 𝐂𝐫𝐞𝐚𝐭𝐞𝐬 𝐈𝐧𝐢𝐭𝐢𝐚𝐥 𝐁𝐫𝐚𝐧𝐜𝐡
The command also creates an initial branch (usually named “master” or “main” depending on the Git version and configuration) pointing to the first commit. This commit is often referred to as the “initial commit.”
• 𝐂𝐫𝐞𝐚𝐭𝐞𝐬 𝐀𝐝𝐝𝐢𝐭𝐢𝐨𝐧𝐚𝐥 𝐅𝐢𝐥𝐞𝐬
Some additional files, like 𝐇𝐄𝐀𝐃, are created to point to the current branch. The 𝐇𝐄𝐀𝐃 file typically points to the latest commit on the branch.
Here’s an example of how to use 𝐠𝐢𝐭 𝐢𝐧𝐢𝐭:
# Navigate to the directory where you want to create a new Git repository
cd /path/to/your/project
# Run the git init command
git init
After running 𝐠𝐢𝐭 𝐢𝐧𝐢𝐭, you’ll see a message indicating that an empty Git repository has been initialized. You can then start adding files to the directory, staging them using 𝐠𝐢𝐭 𝐚𝐝𝐝, and committing changes using 𝐠𝐢𝐭 𝐜𝐨𝐦𝐦𝐢𝐭 to begin tracking the project's version history.
...