Table of contents
If you're new to programming, you may be wondering what GitHub is and why you should care about it. GitHub is a web-based platform used by developers to store and share their code with others. It's an essential tool for anyone looking to collaborate on a project or showcase their work.
Steps to follow -
To get started with GitHub, you'll need to create an account. Once you've signed up, you can create a new repository to store your code. A repository is a collection of files associated with a project. You can create a new repository by clicking on the "New" button on your GitHub dashboard or you can use GitHub CLI.
Creating a GitHub repository:
Go to GitHub.com and log in to your account.
Click on the "+" icon in the top right corner and select "New repository".
Give your repository a name, and a short description (optional), and choose whether it should be public or private.
Click on "Create repository" to create your new GitHub repository.
Cloning the repository:
Open your command prompt or terminal.
Navigate to the directory where you want to clone your repository using the
cd
command.Type the following command to clone your repository:
gh repo clone <username>/<repository-name>
Replace
<username>
and<repository-name>
with your GitHub username and the name of the repository you just created.
Adding files to the repository:
Navigate to the cloned repository on your local system using the
cd
command.Create a new file or add an existing file to the repository using your preferred text editor.
Save the file in the cloned repository.
Creating a commit message:
Once you have added or edited files in your repository, you need to create a commit message to record the changes.
Use the following command to create a commit message:
git commit -m "Your commit message"
Replace "Your commit message" with a short description of the changes you made to the repository.
Pushing changes to the GitHub repository:
Finally, you need to push your changes to the GitHub repository.
Use the following command to push your changes:
git push
This will push your local changes to the remote GitHub repository.
That's it! You have successfully created a GitHub repository, cloned it to your local system, added files to it, created a commit message, and pushed your changes using GitHub CLI.
Congratulations, you've just pushed your first code to GitHub!
Conclusion-
In conclusion, GitHub is an essential tool for any developer looking to collaborate on a project or showcase their work. By following the steps outlined above, you can get started with GitHub and start sharing your code with the world.