Introduction
In the previous article, I described more details on the configuration of git in the local machine, git clone and pull commands, and how to implement it and create public and private repositories and their differences.
In this article, I will describe the below-mentioned points in detail.
- Git complete flow.
- How to push changes from local git to GitHub.
- What are git add, git commit, git status, and git push commands?
- How developers share code from a single repository.
Note. Before going through this session, please visit my below-mentioned session related to Git and GitHub.
Let's understand Git Flow with an example.

Here in my GitHub account, I have created two repositories called SatyaOne and SatyaTwo. Now I describe this example by taking the repository calledSatyaTwo. On this SatyaTwo repository, there are two developers i.e. Local Dev One and Local Dev Two. These two developers are from different locations. Local Dev One is from the UK location and local Dev Two is from the India location. HereLocal Dev One is working on two different projects. So, the local Dev One was cloned from the two different repositories
called SatyaOne and SatyaTwo. HereLocal Dev Two is working on one project. So, Local Dev Two cloned from one repository calledSatyaTwo. So, How do create a repository and clone a repository, For this you need to visit my previous articles which links are mentioned as above.
Now I created two different folders called Dev1 and Dev2 in my local machine and clone theSatyaTwo repository from GitHub using Git Bash. After a successful clone, the output is shown below,
SatyaTwo Repo in GitHub

Local Dev one /Dev1 clone SatyaTwo Repo

Local Dev two /Dev2 clone SatyaTwo Repo

Now Local Dev One and Local Dev Two clone a single repository called SatyaTwo. Here are the physical files which means where we created the files in local repositories that are nothing but the workspace. There is one workspace for each developer called Workspace One.
Workspace one for local Dev One

Workspace one for local Dev Two

Here .git folder and README.md are nothing but physical files. So, when I create any physical files locally and want to push those files to the GitHub repository then first I need to add those files in the staging area or logical area in Workspace One. It should not be a physical area.
What Is This Staging Area?
For example, I created or modified 10 more files in my local but I want to push only 2 files out of 10 files to the GitHub repository. So, In that case, I want to add these 2 files to my staging area. These 2 files in the staging area indicate that they are ready to be committed.
What Is This Commit?
Moving the files from the staging area to our local git repository. It is nothing but a commitment. Once the files are committed to the .git repository which is my local repository then I can push the files to the GitHub repository.
So, To move our changes from the local to the GitHub repository we need to follow the below steps.
- We have to add our files to the staging area
- We commit to the local git repository which is present in our local machine
- We push them to the GitHub repository
When we commit any files to the local git repository, It will create a unique version ID for tracking purposes. So, The same version ID will be pushed to the GitHub repository along with changes or files.
Let's Understand In Practical
As per the earlier discussion, I already have created a workspace for Local Dev One and Local Dev Two. Here in the Local Dev Two workspace, I will add a new file calledMyFile.cs.

Then I open Git Bash in the Local Dev Two workspace as shown below image.

To get the new files along with existing files that are present in the Local Dev Two workspace as shown below.

To get the content of this new file called MyFile.cs as shown below.

To move this new file from local git to my GitHub repository SatyaTwo, We need to add this new file to the staging area using a command called git add as shown below,
Full command is
git add MyFile.cs

Before executing this command I will show you a very important command called git status as shown below.

Untracked files in the case of MyFile.cs mean this file is not present in the staging area.
So, first, we need to add this new file to the staging area using the git add command as mentioned earlier. After executing this command then check the status and the result will be as shown below.

Changes to be committed in case ofMyFile.cs means this file is now present in the staging area and it is now ready to be committed. That means my physical files can't commit directly into local git. So, for this, I need to add this file from physical files to the staging area, and from the staging area we can commit directly into the local git repository. Now my files are added in the staging area and I will commit these files to the local git repository. For this, I need a command called git commit.
Full command is
git commit -m "Add new file called MyFile.cs"
Here is the message or comment I added that is"Add a new file called MyFile.cs". That indicates what is the purpose behind this commitment. So, That other users can easily identify the specific commit reason in the GitHub repository.





























Join the conversation! Your thoughts help the community grow.