Git is a version control system. It is designed to handle large projects with many contributors.
Say you are adding a new feature to the current application, but you break it and the whole application stops running. Without version control, you would have to reverse all the code you have written. With version control, you can go back to the working version with one command.
Setting up Git in your project root directory
First, initialise git in your project:
git init
Then add your changed files to the commit. The dot after add means everything:
git add .
Check the status of the files that have been added:
git status
Commit your changes with a message that says what you did in this commit:
git commit -m "Initial commit"
Pushing your code to a remote repository
A remote repository is your live GitHub repository, which is not stored on your computer. Create a new repository on GitHub, give it a name and description, choose Public or Private, copy the repository link, then add it to your project:
git remote add origin https://github.com/<your-username>/<your-repo>.git
Now push the code to your remote branch:
git push -u origin master
Here master is the branch name of your remote repository. You can create multiple branches and manage them separately.