Create a new project in git repository windows command line
Here are the steps to create a new project in a Git repository using the Windows Command Line:
Step 1: Open the Command Line
Open the Command Prompt or PowerShell on your Windows machine. You can do this by:
- Pressing the Windows key + R to open the Run dialog box, typing
cmd
, and pressing Enter. - Right-clicking on the Start button and selecting "Command Prompt (Admin)".
- Using the PowerShell shortcut (usually found in the Start menu).
Step 2: Navigate to the Directory where you want to create the project
Use the cd
command to navigate to the directory where you want to create your new project. For example:
cd C:\Users\YourUsername\Documents\Projects
Replace YourUsername
with your actual Windows username.
Step 3: Initialize a new Git repository
Use the git init
command to initialize a new Git repository in the current directory:
git init
This will create a new directory called .git
in your current directory, which will contain the Git repository.
Step 4: Create a new directory for your project
Use the mkdir
command to create a new directory for your project:
mkdir myproject
Replace myproject
with the name you want to give your project.
Step 5: Move into the new project directory
Use the cd
command to move into the new project directory:
cd myproject
Step 6: Create your project files
Create the files and directories for your project. For example, you can create a README.md
file and a src
directory:
echo "# My Project" > README.md
mkdir src
Step 7: Add the files to the Git repository
Use the git add
command to add the files to the Git repository:
git add.
The dot (.
) refers to the current directory and all its contents.
Step 8: Commit the changes
Use the git commit
command to commit the changes:
git commit -m "Initial commit"
The -m
option allows you to specify a commit message.
That's it! You have now created a new project in a Git repository using the Windows Command Line.