How to Use Git with Ionic 2 Projects

How to Use Git with Ionic 2 Projects

Follow Josh Morony on

Learn Ionic with Josh ☕

Hey, I hope you enjoy the article.

If you want a weekly update with my newest content, access to the blog's bonus content, or you want to sign up for one of my free beginner or advanced email courses just enter your details here or in the form below.

Git is an essential tool for developers, but it can be a bit intimidating at first. It has massive benefits even if you are just working by yourself, but once you start working in a team environment it becomes an absolute essential. In short, using Git will allow you to:

  • Create an online backup of your code
  • Maintain revision history, easily allowing you to roll back to previous versions of your code
  • Collaborate with others on the same codebase

A Git repository can be synced with a remote (online) repository, which is where sites like GitHub and BitBucket come in. By creating a remote repository, your code will be backed up online if you ever lose it, and you can also collaborate with others through the remote repository.

For the most part, working with Git in Ionic 2 is no different than using it with any other codebase. However, there are some things you need to know about Ionic 2 projects (or more generally, codebases that use npm) when working with Git.

This video tutorial is a very basic introduction to Git, and is suitable for people who have never used Git or people who are having trouble getting their Ionic 2 projects working with Git. It covers:

  • How to initialise a new Git repository
  • How to push code to a remote repository using BitBucket (but the same process applies to GitHub)
  • How to pull someone else’s code to your local machine
  • The essential commands you need to know when working with Git (just the bare minimum)

Here’s the video (and make sure to check out the video notes below):

Video Notes

Creating a Repository

  • git init is used to initialise a new git repository

Working with a Repository

  • git add . can be used to add all new or modified files that you want to commit
  • git add /path/to/file only adds a specific file
  • git commit -m "some message" will commit the files added
  • git push will push committed files to the remote repository

Pulling in Changes

  • git fetch will pull in changes from the remote repository (i.e. if someone else has been working on the codebase as well)
  • git rebase will apply any changes retrieved from the remote repository to your local code, and also apply the changes you have already made automatically (as long as there are no conflicts)

If you enjoyed this article, feel free to share it with your friends ☝

Check out my latest videos: