Explore Courses
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Birla Institute of Management Technology Birla Institute of Management Technology Post Graduate Diploma in Management (BIMTECH)
  • 24 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Popular
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science & AI (Executive)
  • 12 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
University of MarylandIIIT BangalorePost Graduate Certificate in Data Science & AI (Executive)
  • 8-8.5 Months
upGradupGradData Science Bootcamp with AI
  • 6 months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
OP Jindal Global UniversityOP Jindal Global UniversityMaster of Design in User Experience Design
  • 12 Months
Popular
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Rushford, GenevaRushford Business SchoolDBA Doctorate in Technology (Computer Science)
  • 36 Months
IIIT BangaloreIIIT BangaloreCloud Computing and DevOps Program (Executive)
  • 8 Months
New
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Popular
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
Golden Gate University Golden Gate University Doctor of Business Administration in Digital Leadership
  • 36 Months
New
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
Popular
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
Bestseller
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
IIIT BangaloreIIIT BangalorePost Graduate Certificate in Machine Learning & Deep Learning (Executive)
  • 8 Months
Bestseller
Jindal Global UniversityJindal Global UniversityMaster of Design in User Experience
  • 12 Months
New
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in AI and Emerging Technologies (Blended Learning Program)
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
ESGCI, ParisESGCI, ParisDoctorate of Business Administration (DBA) from ESGCI, Paris
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration From Golden Gate University, San Francisco
  • 36 Months
Rushford Business SchoolRushford Business SchoolDoctor of Business Administration from Rushford Business School, Switzerland)
  • 36 Months
Edgewood CollegeEdgewood CollegeDoctorate of Business Administration from Edgewood College
  • 24 Months
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with Concentration in Generative AI
  • 36 Months
Golden Gate University Golden Gate University DBA in Digital Leadership from Golden Gate University, San Francisco
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA by Liverpool Business School
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA (Master of Business Administration)
  • 15 Months
Popular
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Business Administration (MBA)
  • 12 Months
New
Deakin Business School and Institute of Management Technology, GhaziabadDeakin Business School and IMT, GhaziabadMBA (Master of Business Administration)
  • 12 Months
Liverpool John Moores UniversityLiverpool John Moores UniversityMS in Data Science
  • 18 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityMaster of Science in Artificial Intelligence and Data Science
  • 12 Months
Bestseller
IIIT BangaloreIIIT BangalorePost Graduate Programme in Data Science (Executive)
  • 12 Months
Bestseller
O.P.Jindal Global UniversityO.P.Jindal Global UniversityO.P.Jindal Global University
  • 12 Months
WoolfWoolfMaster of Science in Computer Science
  • 18 Months
New
Liverpool John Moores University Liverpool John Moores University MS in Machine Learning & AI
  • 18 Months
Popular
Golden Gate UniversityGolden Gate UniversityDBA in Emerging Technologies with concentration in Generative AI
  • 3 Years
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (AI/ML)
  • 36 Months
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDBA Specialisation in AI & ML
  • 36 Months
Golden Gate University Golden Gate University Doctor of Business Administration (DBA)
  • 36 Months
Bestseller
Ecole Supérieure de Gestion et Commerce International ParisEcole Supérieure de Gestion et Commerce International ParisDoctorate of Business Administration (DBA)
  • 36 Months
Rushford, GenevaRushford Business SchoolDoctorate of Business Administration (DBA)
  • 36 Months
Liverpool Business SchoolLiverpool Business SchoolMBA with Marketing Concentration
  • 18 Months
Bestseller
Golden Gate UniversityGolden Gate UniversityMBA with Marketing Concentration
  • 15 Months
Popular
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Corporate & Financial Law
  • 12 Months
Bestseller
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Intellectual Property & Technology Law
  • 12 Months
Jindal Global Law SchoolJindal Global Law SchoolLL.M. in Dispute Resolution
  • 12 Months
IIITBIIITBExecutive Program in Generative AI for Leaders
  • 4 Months
New
IIIT BangaloreIIIT BangaloreExecutive Post Graduate Programme in Machine Learning & AI
  • 13 Months
Bestseller
upGradupGradData Science Bootcamp with AI
  • 6 Months
New
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
KnowledgeHut upGradKnowledgeHut upGradSAFe® 6.0 Certified ScrumMaster (SSM) Training
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutCertified ScrumMaster®(CSM) Training
  • 16 Hours
upGrad KnowledgeHutupGrad KnowledgeHutLeading SAFe® 6.0 Certification
  • 16 Hours
KnowledgeHut upGradKnowledgeHut upGradPMP® certification
  • Self-Paced
upGrad KnowledgeHutupGrad KnowledgeHutAWS Solutions Architect Certification
  • 32 Hours
upGrad KnowledgeHutupGrad KnowledgeHutAzure Administrator Certification (AZ-104)
  • 24 Hours
KnowledgeHut upGradKnowledgeHut upGradAWS Cloud Practioner Essentials Certification
  • 1 Week
KnowledgeHut upGradKnowledgeHut upGradAzure Data Engineering Training (DP-203)
  • 1 Week
MICAMICAAdvanced Certificate in Digital Marketing and Communication
  • 6 Months
Bestseller
MICAMICAAdvanced Certificate in Brand Communication Management
  • 5 Months
Popular
IIM KozhikodeIIM KozhikodeProfessional Certification in HR Management and Analytics
  • 6 Months
Bestseller
Duke CEDuke CEPost Graduate Certificate in Product Management
  • 4-8 Months
Bestseller
Loyola Institute of Business Administration (LIBA)Loyola Institute of Business Administration (LIBA)Executive PG Programme in Human Resource Management
  • 11 Months
Popular
Goa Institute of ManagementGoa Institute of ManagementExecutive PG Program in Healthcare Management
  • 11 Months
IMT GhaziabadIMT GhaziabadAdvanced General Management Program
  • 11 Months
Golden Gate UniversityGolden Gate UniversityProfessional Certificate in Global Business Management
  • 6-8 Months
upGradupGradContract Law Certificate Program
  • Self paced
New
IU, GermanyIU, GermanyMaster of Business Administration (90 ECTS)
  • 18 Months
Bestseller
IU, GermanyIU, GermanyMaster in International Management (120 ECTS)
  • 24 Months
Popular
IU, GermanyIU, GermanyB.Sc. Computer Science (180 ECTS)
  • 36 Months
Clark UniversityClark UniversityMaster of Business Administration
  • 23 Months
New
Golden Gate UniversityGolden Gate UniversityMaster of Business Administration
  • 20 Months
Clark University, USClark University, USMS in Project Management
  • 20 Months
New
Edgewood CollegeEdgewood CollegeMaster of Business Administration
  • 23 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
The American Business SchoolThe American Business SchoolMBA with specialization
  • 23 Months
New
Aivancity ParisAivancity ParisMSc Artificial Intelligence Engineering
  • 24 Months
Aivancity ParisAivancity ParisMSc Data Engineering
  • 24 Months
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGrad KnowledgeHutupGrad KnowledgeHutData Engineer Bootcamp
  • Self-Paced
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
KnowledgeHut upGradKnowledgeHut upGradBackend Development Bootcamp
  • Self-Paced
upGradupGradUI/UX Bootcamp
  • 3 Months
upGradupGradCloud Computing Bootcamp
  • 7.5 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 5 Months
upGrad KnowledgeHutupGrad KnowledgeHutSAFe® 6.0 POPM Certification
  • 16 Hours
upGradupGradDigital Marketing Accelerator Program
  • 05 Months
upGradupGradAdvanced Certificate Program in GenerativeAI
  • 4 Months
New
upGradupGradData Science Bootcamp with AI
  • 6 Months
Popular
upGradupGradFull Stack Software Development Bootcamp
  • 6 Months
Bestseller
upGradupGradUI/UX Bootcamp
  • 3 Months
PwCupGrad CampusCertification Program in Financial Modelling & Analysis in association with PwC India
  • 4 Months
upGradupGradCertificate Course in Business Analytics & Consulting in association with PwC India
  • 06 Months
upGradupGradDigital Marketing Accelerator Program
  • 05 Months

How to Use GitHub? Step-by-Step GitHub Tutorial for Beginners

Updated on 23 September, 2022

9.3K+ views
13 min read

GitHub is possibly the most famous and widely used open-source platform amongst developers. Launched by Linus Torvalds in 2005, Git is a version control software and collaboration platform that initially only supported Linus kernel.

Git is used as a storage space for the content which is programming code written by different programmers, designers, and developers. It isn’t necessarily written by a single developer, more often than multiple developers are working on real-life projects. Git eliminates any conflicts and facilitates coordination between developers.

Git is basically a code-hosting platform where there is uninterrupted accessibility to open-source programming frameworks, libraries, and languages. It hosts the largest community of tech developers in the world.

Enrol for the Machine Learning Course from the World’s top Universities. Earn Masters, Executive PGP, or Advanced Certificate Programs to fast-track your career.

Git also allows users to store the previous iterations of code in a historical form which can be revisited and reviewed as required. It consists of a branch system to help developers work independently on separate tasks. It also allows you to host a website from your repository.

GitHub’s large base is used to deduce useful insights on programming languages and frameworks. For instance, as per its annual The State of the Octoverse report, the most popular GitHub project of 2019 was the open-source Microsoft/vscode with 19,100 contributors. 

In this article, we will take a look at the installation process of Git, and find out how to use GitHub. So let’s get started!

How to install Git? 

Step 1: Create an account on GitHub.

Visit GitHub‘s Sign Up page and create your account.

The installation process is complete by signing up for an account. However, if you plan to use GitHub on your local computer, you need to install Git. This can be done by either downloading Git and installing it using your package manager. We will do this using CLI. 

Here are the steps to follow:

1. Update the packages:

sudo apt update

2. Start the installation process of Git and GitHub using apt-get:

sudo apt-get install git

3. Verify that the installation is complete and correct:

git –version

4. Enter the commands below with details of your username and email ID to indicate where your work will be saved. Make sure the email ID you use is the same that you entered while creating your account on GitHub:

git config –global user.name “<Your name here>”

git config –global user.email “xyz_abc@mail.com”

You have successfully installed Git and can access GitHub from your computer.

Step 2: Getting started on GitHub

Now that you have completed the installation process, let’s create a new repository. 

A repository is typically where you store your project. You can either store it on your computer or GitHub. You can also store it on a third online storage host. A repository can store text, image, or another multimedia format. 

Here are the steps to follow to create a repository:

Case 1: Creating a new repository using GitHub

1. Open the GitHub website and click on the “+” sign. Select New Repository from the drop-down menu.

Source

  1. Name the repository, and add a description (optional).
  2. Tick the box that says Initialize this repository with a README, and press on the green Create repository button.

Source

Your repository is successfully created! 

The three ‘trees’ in your repository indicate: 

  1. Working directory.
  2. Index or staging area. 
  3. Head.

A GitHub repository is set to public by default, meaning anyone can view it.

1. The next step is to clone your repository to your computer. This will create a copy of your repository on your local computer. To do so, go to the repository page, and copy the “HTTPS” address.

Source

2. Open your terminal and enter the following command. It will create a copy of the host address repository: 

git clone [HTTPS ADDRESS]

3. Once your repository is copied to your computer, you can move it accordingly by entering the following command: This will take you to the specific directory where your repository is located:

cd [NAME OF REPOSITORY]

You can also access your repository by locating it on the computer user interface. However, to ensure it is saved on GitHub, we use the Commit operation (which we will discuss ahead).

NOTE: You might encounter an error with Git commands which will direct you to a CLI based text-editor. In this case, simply entering “:q” will help you shut it down. 

Now that you have arrived at your repository directory, there are four steps to follow: 

1. “status”: Verify the files that have been modified. Typing the following command will display the list of changes made:

git status

2. “add”: Use the following command to upload the file consisting of the changes:

git add [FILENAME] [FILENAME] […]

For example, we are adding an HTML file below:

git add sample.html

3. “commit”: To disclose the changes made, we will add a small description for users. This also helps to keep track of the changes so make sure your message is concise and explanatory. For example, to show that we added a sample HTML file, here’s how we will use the commit command:

git commit -m “Included a sample HTML file that contains basic syntax”

4. “push”: Now, we must create a duplicate instance for our file on a remote server using the ‘push’ command. To use the push command, we need the name of the remote server. If you don’t know the name, this is how you can check:

git remote

The remote server’s name is usually named origin, as is evident in the image above. Now, that we have our name, we can push our files to the origin. Use the following command:

git push origin master

Visit your repository on GitHub and you will find the sample.html file added to the remote. 

Case 2: Creating a new repository using the project directory

You can also create a new repository using your project directory. The procedure includes working on your local computer, creating the repository on GitHub, and pushing it to the remote. 

(Push refers to sending a file to GitHub while Pull refers to receiving from GitHub.)

1. To create a new repository using the project directory, we will first ensure that we are in the right directory on our terminal. Alson since a directory doesn’t by default indicate a Git repository, we will convert it into one using the following command:

git init

2. Now we will check which files we have:

git status

3. The image shows we have two files we can “add” to the repository. Use the following command: 

git add [FILENAME] [FILENAME] […]

We can “add” all files using the add command:

git add 

4. Once the add command is executed, verify that the files are indeed added:

git status

If the files appear in green, the add process was a success.

1. Now, we will add a small description to indicate changes made. We will use the commit command:

git commit -m “Adding web Survey form”

2. Now, we need to add a remote. To do so, visit GitHub, create a new repository as explained above, and store it with a name of your choice. Press the Create repository button.

  1. Note down the HTTPS address.
  2. Create a remote for your repository using the following command:

git remote add origin [HTTPS ADDRESS]

3. Verify if the remote is added or not using the following command. If the output is “origin,” the remote was successfully added:

git remote

4. Use the push command to send the project to GitHub:

git push origin master

Also Read: Top AI Projects in GitHub

GitHub Operations

1. Commit Command

Using the Commit Command, you can save any changes you made to your file. Every time you commit a file, it is recommended that you add a message or description highlighting the changes you made to your repository. It serves as a history that helps keep track of the various iterations of your file. It also ensures transparency with other developers or programmers in case they return to view your repository after you’ve made a commit. 

Here are the steps involved in writing a commit using the Commit Command:

  1. Go to your repository.
  2. Open the “readme- changes” file created by you. 
  3. You will find an “edit” button or a pencil icon on the right corner of the file. Click on it. 
  4. You will be directed to an editor where you can make the required changes to your file. 

Source

  1. Add a commit message to highlight the changes you’ve made.
  2. Click Commit changes to save the file.

Source

Making changes to your file is also possible through files/notebooks on your computer.

Next, let us understand the pull command.

2. Pull Command

Pull Command informs GitHub contributors of the changes made to a file and allows them to view or merge them with the master file. Now that the commit command is complete, contributors can pull the file, and when they have finished using it, the file can be merged. We use the Pull command to draw a comparison of the files after changes are made. It also allows you to solve any conflicts manually. 

Here are the steps to follow to execute the Pull command on GitHub:

  1. Open the Pull requests tab.
  2. Press on New pull request.
  3. Open the file readme- changes to view any changes in the two files stored in the repository.
  4. Press on Create pulls request to “discuss and review the changes in this comparison with others.”

Source

  1. Add a title and a small description highlighting the changes made and press Create pull request

Now, we will understand how we can merge this pull request.

3. Merge Command

The merge command is used to merge the pull request into the master branch. This is indicated in the master branch/ read-me

Here are the steps to merge your pull request.

  1. Press on the Merge pull request.
  2. Press on Confirm Merge when prompted.
  3. If there are conflicts, you can resolve them manually. In case of no conflicts, you can delete the branch after merging into the master branch.

Image Source

Cloning and Forking GitHub Repositories 

Cloning refers to creating a duplicate file or a copy of a GitHub repository to use for your personal needs. 

Forking, on the other hand, allows you to access code from your public repository. Any changes you make in the original repository will reflect in the forked repository. However, the vice versa of this is not true. If you want the changes to reflect, you will need to make a pull request.

Here are a few other helpful commands for GitHub: 

1. To look up commands to run:

git help

2. To look up the most common commands:

git help clone

3. To view the commit history of a repository 

git log 

4. To view a developer’s commits 

git log –author=<name> 

5. To view changes that aren’t yet staged or added:

git diff

Related: GitHub Open Source Projects

Benefits of GitHub

  1. You can serve as a contributor to open-source projects. This can be done using the fork and pull request command.
  2. GitHub supports integration with Amazon, Code Climate, Google Cloud, etc.
  3. As a contributor, you get excellent feedback which you can use to create documentation for users.
  4. It allows multiple developers to work on a real-life project where the tasks are defined individually. 
  5. It provides an excellent track of revisions for developers to review changes. 
  6. GitHub is an effective showcasing platform for your skills which can help you attract job opportunities.

Conclusion 

This brings us to the end of the article. The operations highlight how Github works, and what its features are. We hope you now know how to use Git and GitHub.

If you are curious to master Machine learning and AI, boost your career with an advanced course of Machine Learning and AI with IIIT-B & Liverpool John Moores University.

Frequently Asked Questions (FAQs)

1. Why should you use GitHub?

GitHub is an open-source hosting platform where application developers can upload the code that they write and collaborate with other programmers in the community to improve on it. GitHub is used to host source codes written in various programming languages and helps in tracking changes made to them at every step. This version control feature of GitHub makes it one of the most sought-after code hosting sites – other developers can view your code, fix bugs, and boost efficiency without impacting the experience of other developers or inhibiting the software.

2. Are there any alternatives to GitHub?

There are some other options to using GitHub, and each of those platforms come with their unique uses and USPs. Some of the free-to-use and totally open-source platforms are Launchpad, Sourceforge, Apache Allura, GitBucket, and Gitea. Those that offer free user plans as well are GitLab, Bitbucket, and Git Kraken, among others. Beanstalk, renowned for its robust Git and SVN hosting feature, does not have any free plans, and it is meant for up to 200 users. The others generally support an unlimited number of users. However, GitHub, owned by Microsoft Corporation, is the most popular code hosting site out of all the others.

3. What are the advantages that GitHub offers to developers?

Today, almost all open-source application development projects prefer using GitHub. This is primarily because GitHub brings forth myriad advantages to programmers. The most significant advantage is GitHub’s version control feature that lets you track every change made to your code by any developer; you can easily follow the version history and also roll back as and when necessary. You can easily contribute to your project or any other developer's source code since this is open to all. GitHub offers excellent documentation and guides for any topic that you can think of. You can easily showcase your projects while applying for jobs; companies generally show a higher preference to candidates with GitHub profiles.