Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Full-Stack Web Development with Vue.js and Node

You're reading from   Full-Stack Web Development with Vue.js and Node Build scalable and powerful web apps with modern web stack: MongoDB, Vue, Node.js, and Express

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781788831147
Length 366 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Aneeta Sharma Aneeta Sharma
Author Profile Icon Aneeta Sharma
Aneeta Sharma
Arrow right icon
View More author details
Toc

Table of Contents (12) Chapters Close

Preface 1. Introducing MEVN FREE CHAPTER 2. Building an Express Application 3. Introducing MongoDB 4. Introducing REST APIs 5. Building the Real Application 6. Building Authentication with passport.js 7. Building OAuth Strategies with passport.js 8. Introducing Vuex 9. Testing an MEVN Application 10. Going Live 11. Other Books You May Enjoy

Introducing GitHub

GitHub is a version control service. It is a source code management tool specifically designed to track changes to our code. GitHub also provides features of social networking, such as adding comments, and displaying feeds, which makes it even more powerful because multiple developers can collaborate at the same time in a single application.

Why GitHub?

GitHub is a savior for software engineers. There are several advantages that GitHub provides that make it worthwhile to use. A few benefits that are provided by GitHub are listed here:

  • Tracking code changes: GitHub helps track changes to the code, which means it maintains a history of our code. This enables us to view revisions of our code base made during any time period.
  • Documentation: GitHub provides features for adding documentation, Wikis, and so on to our code bases, and these can be written using the simple markdown language.
  • Graphs and reporting: GitHub provides insight into various metrics, including how many additions and deletions were made to the code, who the top contributors were, and who has the most commits.
  • Bug tracking: Since GitHub tracks all the activities made at every point in time, when something breaks, we can easily backtrack to the point that broke the code. We can also integrate third-party tools such as Travis for continuous integration, which helps us to track and identify bugs easily.
  • Collaboration is easy: GitHub tracks every activity done by every collaborator working on the project and also sends email notifications about the same. It also provides social media features, such as feeds, comments, emojis, and mentions.
  • Hosting our own website: We can also host our own website with GitHub using a feature called GitHub pages. We just need to create a repo for our own project and host it using GitHub pages, which will then make the website applicable to the URL: https://<username>.github.io.

Using GitHub

GitHub is very easy to use. However, to get started using GitHub, we need to least know about a few terminologies that are used in GitHub:

  • Repository/Repo: A repository is a place where all of our code bases are stored. A repository can be either private or public.
  • ssh-key: ssh-key is a way to authorize in GitHub. It stores our identities.
  • Branch: A branch can be defined as multiple states of a repository. The primary branch of any repository is the master branch. Multiple users can work in parallel on different branches.
  • Commit: A commit makes it easy to distinguish between different states of a file at a given time. When we make a commit, a unique identifier is assigned to that commit so what it's easy to check what changes were made in that commit. A commit takes a message as a parameter to describe the type of change that is being made.
  • Push: A push sends the commit that we made back to our repository.
  • Pull: As opposed to pushing, pulling fetches the commit from the remote repository to our local project.
  • Merge: Merging is basically done between multiple branches. It is used to apply changes from one branch to another.
  • Pull requests: Creating a pull request is basically sending the changes that we made to our code base for the approval of other developers. We can start discussions on a pull request to check the quality of code and ensure that the changes don't break anything.
To learn more about the vocabulary used in GitHub, visit https://help.github.com/articles/github-glossary/.

Setting up a GitHub repository

Now that we know the basics of GitHub, let's get started creating a GitHub repository for the project we want to build:

  1. First, create a folder for the application in the root folder. Let's name this application blog:
 $ mkdir blog
  1. Create an account on GitHub at https://github.com/.
  2. Go to your profile. Under the Repositories tab, click New as follows:
  1. Name this repository blog.
  2. Now, on the Terminal, go to the location of this application and initialize an empty repository with this command:
 $ cd blog
$ git init
  1. Now, let's create a file called README.md and write a description for the application and then save it:
 $ echo 'Blog' > README.md
  1. Add this file to GitHub:
 $ git add README.md
  1. Add a commit so that we have a history of this change of code:
 $ git commit -m 'Initial Commit'
  1. Now, to link the local application with the remote repository in GitHub, use this command:
$ git remote add origin https://github.com/{github_username}/blog.git
  1. Finally, we need to push this commit to GitHub:
 $ git push -u origin master

When it's done, visit the GitHub repository where you will find a history of the commits made to our repository, as follows:

That's it. Now, when we want to write changes, we will first create a branch and push the changes to the branch.

You have been reading a chapter from
Full-Stack Web Development with Vue.js and Node
Published in: May 2018
Publisher: Packt
ISBN-13: 9781788831147
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image