- Go to the official Git website.
- Download the version suitable for your operating system (Windows, macOS, or Linux).
- Follow the installation steps.
Verify Installation:
git --versionThis should show you the Git version if it’s installed correctly.
- Go to the official Node.js website.
- Download the latest LTS (Long Term Support) version.
- Follow the installation steps.
Verify Installation:
node --version
npm --versionThis should show the version of Node.js and npm (Node Package Manager).
- Go to GitHub and create a new account (if you don’t have one).
- Once logged in, click on the + icon at the top right and choose New repository.
- Give your repository a name (e.g.,
my-first-repo), and choose whether it should be public or private. - Click Create repository.
- Open VSCode (Download it from here if you don’t have it).
- Open the VSCode terminal by clicking on
Terminal > New Terminalfrom the menu bar.
In the terminal, create a README.md file:
touch README.mdOpen this file in VSCode and add something like:
# My First Repository
This is a simple project to learn Git and GitHub.In the VSCode terminal, run:
git initThis will initialize Git in your project folder and create a .git folder to track all the version control changes.
Set up your Git username and email (the ones you use for GitHub):
git config --global user.name "Your Name"
git config --global user.email "your-email@example.com"Stage and commit your files:
-
Stage the files (add them to Git):
git add . -
Commit the files with a message and select main branch:
git commit -m "Initial commit" git branch -M main
- Go to your GitHub repository and copy the repository URL (e.g.,
https://github.com/username/my-first-repo.git). - In the VSCode terminal, run:
git remote add origin https://github.com/username/my-first-repo.git git push -u origin main
To log in to GitHub through Git on your computer:
-
Run:
git config --global credential.helper cache
-
The next time you push to GitHub, Git will ask for your GitHub username and password.
For two-factor authentication (2FA):
If you use 2FA on GitHub, you will need to use a Personal Access Token (PAT) instead of your password. Generate a PAT here.