- MyFile.cs
- MyFile2.cs
- MyFile3.cs
- README.md
So, for these commited files only one commit ID will be generated but not different commit IDs for each file. In the previous article, I described the details on commit ID in GitHub.
Now, I need to add GitHub repository URL using command git remote add origin https://github.com/satyaCsgithub/SatyaThreeEmptyRepo.git as shown below.
Here origin is the alias of GitHub and https://github.com/satyaCsgithub/SatyaThreeEmptyRepo.git is nothing but the GitHub repo URL. This URL is used for clone purpose as described earlier in my previous article.
Now I check my GitHub repository using command git remote -v as shown below.
Now I need to push these 4 files from local git to My GitHub repositories using command git push origin master as shown below. Here origin is nothing but the alias of GitHub and master is nothing but the name of the default branch. So, When i created a GitHub repository that s created a default branch called master for my repository.
Make Sure Internet Connection Is Active
I got this message when I ran my push command using Git Bash as shown below. This is because to push files to GitHub repository, it requires internet connection to access remote workspace that is GitHub.
After the internet is connected, now I am able to push these files to GitHub repository successfully as shown below,
If I refresh my GitHub repository page then we can see a different interface as expected as shown below. There we can see those pushed files and in this way the GitHub empty repository can be filled with files.
Here we can see one commit -- 4 files are pushed. So, as per earlier discussion it should be one commit ID for 4 files instead of 4 different commit IDs as shown below.
If I click on 1 commit link as shown above then we can see these 4 files with contents with one commit ID as shown below.
Now I modified one file called MyFile3.cs by adding a new line of code as shown below.
In the next step, I will check status of this file. Then add this file to staging area.
In the next step, I will commit this file to local git repository and then push this file from local git repository to GitHub repository as shown below.
Now, we can see the MyFile3.cs with latest changes with commit message and no. of commit is updated to 2 as shown below.
Let's see the latest changes of this MyFile3.cs as modified earlier as shown below. Here We can see a new Commit ID is generated with latest commit changes of this file.
SUMMARY
In this write-up, we have learned the below details,
- Steps to create an empty repository
- Steps to initialize a git repository
- Using this repository how to push the changes to GitHub
- How to add multiple files to staging area using a single command
****Thank You & Stay Tuned For More****