
What Is Git & Github And How To Use Git full Explain
Using GitHub involves several steps, including creating a repository, cloning the repository to your local machine, making changes, committing those changes, and pushing them back to GitHub.
Here is a step-by-step explanation of how to use GitHub with a sample source code:
git clone
Create a GitHub account:
Go to github.com and sign up for an account if you don't already have one.
Create a new repository:
Click on the "+" icon on the top right corner of the GitHub homepage and select "New repository".
Give your repository a name and choose other settings like visibility and licensing.
Click on "Create repository" to create your new repository.
Clone the repository to your local machine:
cd
On your local machine, open a terminal or command prompt.
Navigate to the directory where you want to clone the repository.
Copy the repository URL from the GitHub repository page.
Run the following command in the terminal:
Navigate to the cloned repository:
git status
- In the terminal, change the directory to the cloned repository using the command:
Write or modify the source code:
Open your preferred code editor and create or modify the source code files in the cloned repository.
Commit the changes:
In the terminal, check the status of your repository using the command:
- This will show the modified files in your repository.
git add
- You can also use git add .
to add all the modified files.
git commit -m "Commit message"
git push origin master
Add the files you want to commit using the command:
Commit the changes with a descriptive message:
Push the changes to GitHub:
Push your changes to the GitHub repository using the command:
- If you have created a branch instead of using the master
branch, replace master
with the branch name.
These steps cover the basics of using GitHub with source code. Keep in mind that this is just a brief explanation, and there are many additional features and concepts to explore, such as branching, merging, pull requests, etc.
Verify the changes on GitHub:
Go to your repository on GitHub and refresh the page.
You should see the updated files and code.