Step-by-Step Guide To Git Push Your Project to GitHub for the First Time
A beginners' Guide on how to push project from local repository to Remote Repository (Github) from the first time
Have you been looking for a more straightforward way to push your project from a local repository to Git Hub for the first time? This article is a step-by-step guide to help you push your project folder from the terminal to GitHub quickly.
What is GitHub (Beginners' Definition)
GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere, and anytime. Before we proceed further, I would like to define some terminologies that you might often hear about GitHub.
GitHub Common Terminologies
Version control: A system for tracking changes to a file or set of files over time. This is important for software development, as it allows you to see what changes have been made to your code, and also to revert to a previous version if necessary.
Collaboration: This is the ability to work on a project with other people. This simply means multiple people can work on the same project at a time. GitHub makes it easy to collaborate with others, by allowing you to share your code, assign tasks, and even review each other's work.
How Many People Are Using GitHub
GitHub is used by millions of developers around the world, for both personal and professional projects. It is a popular choice for open-source projects, as it allows developers to easily contribute to and collaborate on projects.
Step-by-Step Guide to Push Your Project to Git Repository for the First Time
If you already have a project on your local repository and would like to push it to your GitHub repository, especially for the first time, then continue reading below.
N.B - _This article is targeted towards those who are pushing their local repository to the git repository for the first time. It also includes how you can authenticate your Github account to complete the connection
Step 1: Download and Install Git
Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency. You can download and Install Git by following the instructions below;
Visit the official Git website: https://git-scm.com/download.
Select your Operating System (e.g. Windows, macOS, Linux/Unix)
Download the latest version for your operating system (I will be using Windows as a case study for this article).
Run the downloaded Installer
Follow the installation prompts. In most cases, you can choose the default options.
Step 2: Setup Git
Open the Terminal
- Search for "Git Bash" or "Git CMD" in your Windows search bar and open it.
Configure Git
- Set your name and email address (used to identify your commits):
git config --global user.name "Your Name"
git config --global user.email "your@email.com"
Step 3: Navigate to your Local Repository
- In your terminal, navigate to the directory where you want to create your new project/repository. For example:
cd /path/to/your/myproject
Initiliaze a New Git Repository
- Run the below command to initialize a new Git repository:
git init
Step 4: Add Your Files and Make Commits
- Add all your Local Files to your Git repository using:
git add .
- Commit the changes to your repository using the below command:
git commit -m "first commit"
Step 5: Create a Remote Repository (GitHub)
Create a GitHub Account:
- If you don't have one already, create a GitHub account from here: https://github.com.
Create a New Repository:
Log in to GitHub and click on the "+" sign in the top right corner.
Select "New repository".
Fill in the repository name, choose visibility, and optionally add a README file.
Click "Create repository".
Step 6: Connect Your Local Repository to Remote Repository (GitHub)
- Add the Remote Repository:
- Copy the HTTPS URL of your remote repository from GitHub (as seen from the screenshot below).
- Link the Remote Repository:
- In your local terminal, add the remote repository URL:
git remote add origin <remote_url>
Step 7: Push to Remote Repository
- Push your local repository to the remote (GitHub):
git push -u origin main
N.B: Yours could be "master" instead of "main"
Step 8: Check GitHub
- Check/Refresh your GitHub repository page, and you should see your files.
Conclusion
Congratulations! You've now set up Git on your Machine (in this case study using Windows), created a new repository, and pushed it to GitHub. Remember, these are the basics, and Git offers a lot more functionality for version control.
Happy coding, and do not forget to like this post if you find it helpful!