Install Git:
If Git is not already installed on your system, you'll need to install it first. You can download and install Git from the official website: Git Downloads.
Configure Git:
After completing the installation, configure Git with your name and email. Open your terminal and run the following commands, replacing "Your Name" and "youremail@example.com" with your user name and email address:
git config --global user.name "Your Name" git config --global user.email "youremail@example.com"
Create a Git Repository:
You can create a new Git repository for your project or start by using an existing one. To create a new repository, navigate to your project's directory in the terminal:
a. First change your working directory
cd /path/to/your/project
b. Initialize Git Repository
git init
Clone the GitHub repository to Your Local Machine
a. Copy the repository git URL from Git Hub.
URL must end with .git
b. Add the GitHub repository to Your Local Machine
git remote add origin remote_repository_url.git
Change the remote_repository_url.git with the copied URL
Adding Files:
Use the
git add
command to add the files you want to commit to the staging area. You can specify individual file names or use wildcards to add multiple files at once.a. To add specific files:
git add file1.txt file2.txt
b. To add all files:
git add .
Commit the Changes:
Once you have added files to the staging area, you can commit them.
git commit -m "Your commit message here"
Push the changes to your GitHub repository:
a. Push all locally made changes to the
main
branch. Make sure to check the branch name.git branch -M main git push -u origin main
Check Your GitHub Profile:
Once you've pushed your changes to GitHub, visit your GitHub repository page in a web browser. You should see your newly committed contributions added to your repository, including the commit messages and timestamps.
Pull repository from Git hub :
- Copy the repository git URL from github.
URL must end with .git
Open the terminal/cmd and navigate to your project's directory
cd /path/to/your/project
Clone the GitHub repository to Your Local Machine
git clone remote_repository_url.git
Change the remote_repository_url.git with the copied URL