Getting Started with GitHub
Table of contents
Are you new to GitHub and curious about how to create a repository, make changes, and push them back to the remote repository? Look no further! In this blog, we'll walk you through the simple process of setting up your first repository on GitHub, making changes, and pushing them back to the remote repository.
Step 1: Create a New Repository on GitHub
Go to https://github.com and log in to your GitHub account. If you don't have an account, sign up for free.
Once logged in, click on the "+" button on the top right corner of the GitHub dashboard and select "New repository."
Give your repository a meaningful name, a brief description, and choose whether it should be public or private.
Click on the "Create repository" button to create your new repository.
Step 2: Clone the Repository to Your Local Machine
Open your preferred terminal or command prompt on your local machine.
Navigate to the directory where you want to clone the repository. You can use the
cd
command to change directories.On the GitHub repository page, click on the green "Code" button and copy the repository's URL.
In your terminal, type the following command and replace
<repository-url>
with the URL you copied:git clone <repository-url>
Press Enter to clone the repository to your local machine.
Step 3: Make Changes to a File in the Repository and Commit
Open the cloned repository on your local machine using your favorite code editor.
Make the desired changes to the file(s) in the repository.
Save the changes you made in the file(s).
Now, let's commit the changes locally using Git:
Open your terminal or command prompt.
Navigate to the root folder of your cloned repository using the
cd
command.Use the following commands to commit the changes:
git add . # This stages all the changes you made. git commit -m "Your commit message here" # Replace the message with a brief description of your changes.
Step 4: Push the Changes Back to GitHub
After committing your changes, it's time to push them back to the remote repository on GitHub:
git push origin main # If you're using the main branch. If your default branch is named differently, use that name instead of 'main'.
Enter your GitHub username and password (or, if you've set up SSH keys, you won't need to enter your credentials).
Press Enter, and Git will push your changes to the remote repository.
Congratulations! You've successfully created a new repository on GitHub, cloned it to your local machine, made changes to a file, and pushed those changes back to the remote repository.
With this basic understanding, you can now collaborate with others on projects, explore version control, and contribute to the world of open-source software. Happy coding!
Subscribe to my newsletter
Read articles from Utsav Gohel directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by