Beginner's guide to GitHub
Tags: codenewbie, teamtanay, github, git
Published: 2020-12-07 14:44:41

##What is Git?
It is an open source version control software. Version control is a system that records changes to a file or set of files over time so that you can keep track of the activities you performed.

In Real life projects, multiple developers work in parallel. So they need a version control system like Git to make sure that there are no code conflicts between them.

##Why do we need it?
* Git makes it easy to contribute to open source projects:
  If you want to contribute to other's projects, you just fork(get 
  a copy of) the project, make your changes, and then make a pull 
  request to the project owner using GitHub's web interface. This 
  way the project owner can look into your changes and include 
  these changes in their project.

* To track changes in your code:
  When multiple people work on a project, it’s hard to keep track 
  of the changes — who changed what, when, and where those files 
  are stored. GitHub takes care of this problem by keeping track 
  of all the changes that have pushed to the repository.

* To showcase your work:
  Are you someone who wants to attract recruiters? GitHub is the 
  best tool you can rely on for this. You will have a higher 
  chance of being recruited if you have maintained a good GitHub 
  account.

##Set up your GitHub account
* Create a GitHub account:

![](https://github.com/panchami6/portfolio_panchami/blob/main/images/Github/sign_up.PNG?raw=true)

* Download and Install GitHub Desktop.

##Git Repositories
A repository is a project that contains multiple files. This repository tracks all the changes made to files in your project, building a history over time.
You can do following actions with a repository.

![alt text](https://github.com/panchami6/portfolio_panchami/blob/main/images/Github/newrepo.png?raw=true "Repository Operations")

* Create a new repository locally:
  Create a local repository by filling all the details.

   ![alt text](https://github.com/panchami6/portfolio_panchami/blob/main/images/Github/createrepo.PNG?raw=true "Create new Repository")

* Clone your repository:
  Cloning a GitHub repository creates a local copy of the remote 
  repository. This allows you to make all of your changes locally 
  rather than directly in the source files of the original 
  repository.

   ![alt text](https://github.com/panchami6/portfolio_panchami/blob/main/images/Github/clonerepo.PNG?raw=true "Clone a Repository")

* Create an existing repository:
  If you have already created a repository, you can select this 
  option and add the existing repository.

   ![alt text](https://github.com/panchami6/portfolio_panchami/blob/main/images/Github/existingrepo.PNG?raw=true "Add Existing Repository")

##Publishing the Repository
After creating a Repository, you can publish this repository to the GitHub web interface.

![alt text](https://github.com/panchami6/portfolio_panchami/blob/main/images/Github/publish.PNG?raw=true "Publish a Repository")

##Git commits
Commits are like a snapshot of your work and the changes you have made. It creates a history of every commit you make. This helps in keeping track of the changes you made to the project.

![alt text](https://github.com/panchami6/portfolio_panchami/blob/main/images/Github/commit.PNG?raw=true "Commit your changes")

##Push your changes to the main branch
After committing to the changes you have made to the project, you need to push the changes to the main branch.

![alt text](https://github.com/panchami6/portfolio_panchami/blob/main/images/Github/push.PNG?raw=true)

##Create a new branch
If you want to make a new feature but you are worried about making changes to the main project and spoiling it while implementing the feature. This is where git branches come in.
Click on the New Branch --> Give a name to the branch --> Create Branch.

![alt text](https://github.com/panchami6/portfolio_panchami/blob/main/images/Github/branch.PNG?raw=true "New Branch")

![alt text](https://github.com/panchami6/portfolio_panchami/blob/main/images/Github/createbranch.PNG?raw=true "Create Branch")

##Create a Pull Request
If you want to contribute or collaborate with other projects, you need to follow these steps:

* Find a project you want to contribute to
* Fork it

   ![alt text](https://github.com/panchami6/portfolio_panchami/blob/main/images/Github/fork.PNG?raw=true "Fork")
* Clone it to your local system
* Make a new branch
* Make your changes
* Push it back to your repository
* Click on the Compare button
   After you push the changes you have made to the project, go to your repository on GitHub web interface, click on the Compare button.

![alt text](https://github.com/panchami6/portfolio_panchami/blob/main/images/Github/compare.PNG?raw=true "Compare")
* Click on Create pull request to open a new pull request

![alt text](https://github.com/panchami6/portfolio_panchami/blob/main/images/Github/pullrequest.PNG?raw=true "Pull Request")

###Happy learning😊