Setting up Git and using it for version control involves a few key steps, including installing Git, creating a repository, making commits, and using push and pull commands to sync your work with a remote repository. Here's a detailed guide to help you get started:
Install Git on Windows
Download the Git installer from git-scm.com.
Run the installer and follow the instructions.
Set Up Git
After installing Git, you need to configure it with your user information.
usimg this commands
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
To Know the git version using
use the below command
git --version
Linux command
To change directory
Create a New Repository
Create a Local Repository:
Open a terminal or command promptNavigate to the directory where you want to create the repository.
Making Commits
Add Files to the Repository:
Add files to the staging area using the git add command. This prepares the files to be committed.
To add all files:
Command:
git add .
Commit Changes:
Commit the staged files with a descriptive message:
sh
Copy code
git commit -m "Your commit message"
Pushing Changes
To push your commits to a remote repository (like GitHub), you need to set up a remote repository and link it to your local repository.
Add Remote Repository:
Create Remote Repository
sh
Copy code
git remote add origin
https://github.com/username/repository.git
Push Changes:
Push your commits to the remote repository:
Command
git push origin master
Pulling Changes
To update your local repository with changes from the remote repository:
Edit
Pull Changes:
Copy this command
git pull origin master























