Getting Started With Git and Github: Beginner's Guide

muhammadzeeshan03

Muhammad Zeeshan

Posted on June 30, 2023

Getting Started With Git and Github: Beginner's Guide

Hi, If you are looking for a beginner guide to git and github, you are at right place. In this we will be exploring about what is git and github. And how we can push and share our code with others.

Introduction

In today's software development system we need to share and maintain the different versions of our code. So, that developer working in a collaborative system can work on others code and can view the code of different collabotors. Git and github serve the purpose.

Git

Git is a free and open source distributive and collaborative version controlling system. It's main purpose it to help developers in management of source code effectively. Git has changed the way developers work. Using git developers can keep track of their work, collaborate seamlessly and can manage all of their work very easily. One of it's imporatant and powerful feature is it's ability is to allow developers to create lines and version of code using branching and merging feature.

Github

At high level github is code hosting platform mainly used for collaboration and version control. It helps developer in store and management of code as well as keep track of changes in the code.

Let's explore how we can use both.
For this i will be using Windows Operating system.

Setup

First of all install git on your machine. For this you can download and install git from here. you can read more about git and all its features here.

After installing git restart you machine and check installation by running git --verison in terminal.

Now create an account on github if you don't have.

github Sign up page.

After creating an account create a github repo to push your code.
To create repo click new and you will be shown a page like this.

Repository page.

Add repository name. you can make this private or public. Fill required details and click create new.

open terminal in the directory of your code that you want to upload to github.

First of all setup your username and email.

git config --global user.name "Your Name"
Enter fullscreen mode Exit fullscreen mode
git config --global user.email "your.email@example.com"
Enter fullscreen mode Exit fullscreen mode

replace "Your Name" and "your.email@example.com" with the name and email you want to setup.

check name and password.

# Check
git config user.name
git config user.email

Enter fullscreen mode Exit fullscreen mode

Now it's time to upload code to github.

run git init

Initialize the repository to current directory.

Now setup the remote origin.

git remote add origin https://github.com/username/repository.git
Enter fullscreen mode Exit fullscreen mode

Or you can copy this from github.

Now add all the files to staging area.

git add <filename>

To add file changes in the current directory and its subdirectories to staging area.

git commit -m "Commit Message"

Add your commit message to keep track of code.

git branch -M main

Setup head to main branch.

git push -u origin main

This will push you code to github now open github to check your code.

That's all for this part 💻 . In the later we will explore some advance features of github.

References

https://github.com/

https://git-scm.com/

💖 💪 🙅 🚩
muhammadzeeshan03
Muhammad Zeeshan

Posted on June 30, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related