Understanding The Git Workflow: Working Directory, Staging, Commit and Push
Imagine working on a project for several weeks. You make hundreds of changes across dozens of files. Then your computer crashes. Which version of your project was working yesterday? What did you change? Which changes did your colleague make? And how do you combine everyone's work without overwriting each other's changes? This is where Git comes in. What is Git? Git is an open-source system that enables users to manage their projects, from a single file to large projects. Git is basically a version control system. It provides the necessary resource to help one manage files in the local machine, track the files that have been changed, attach a pointer which marks files which were changed, who did it, and when, and to make it redundant, these files can be pushed into a remote shareable project called repository in Github . Git also has something very key that is called branches . A branch is basically an isolated area of your project where you can work on a copy of the main project without making changes to the main work. Once you are done working on your branch, Git makes it possible to merge all the changes to the main branch. For this article, I will cover these concepts, guiding one on the step by step process of how to do all this. This article assumes that one has Git installed and configured, and has a Github account. We shall also assume that one has a text editor installed, or is conversant with commands in the terminal. We shall cover these concepts in another article. Creating a Project On Your Machine To start, we need to create a folder where we shall be working on our project. On your machine, you can use the good old right click and select New Folder, or, if in terminal, use the command mkdir as follows: mkdir new_project This creates a folder called new_project We shall then open our folder in the terminal, so that we can do the following: Initialize Git Create a file Stage it Commit it Link local repository to remote repository Push to Github account I