Getting Started With Git and Github: Beginner's Guide
Tags: github, git, beginners, codenewbie
Published: 2023-06-30 09:41:59

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](https://git-scm.com/download/win). you can read more about git and all its features [here](https://git-scm.com/). 

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

Now create an account on [github](https://github.com/) if you don't have.

![github Sign up page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h9uejafgifhwdlzp52we.png).

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](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tylh0ad2tm89j947i7o1.png). 

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"
```

```
git config --global user.email "your.email@example.com"
```

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

```

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
```
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://github.com/)
## [https://git-scm.com/](https://git-scm.com/)