- git config user.email "satya_inet@xxxx.com"
- git config user.name "sa**aCsgit**"
Using the above command mention your own Email-ID and User Name during creation of GitHub account. Check the image as shown below and try the same,
Then run the below command as shown in image for commit,
Now my new file is committed successfully to local git repository from staging area. Here you get a message that 1 file changed, 25 insertions. That means 1 file changed is nothing but one new file called MyFile.cs and 25 insertions is nothing but the total number of lines in this new file as shown below,
Now I will run git status command and here you see there is no new files or existing files in local which means all files are committed to local git repository. Let's see as below image,
Then I need to keep the same new file from local git repository to GitHub repository. For this we need a command called git push.
Full command name : git push origin main
Authorize Git Credential Manager
First it asks for authorization as shown below image,
After click on this button, It will ask for your GitHub account password. After given proper credentials your authentication will be successful as shown below,
Then, It starts pushing changes from local repository to GitHub repository as shown below,
Now I can see new file in my GitHub repository with comments given during commmit command as shown below,
Also you can see the updated content of this file as shown below,
Let's know about sharing file between different Developers
Here the Local Dev One wants same file as Local Dev Two has already pushed the file to GitHub repository. Local Dev One connects to same GitHub repository.
For this Local Dev One will open Git Bash and type command git pull as shown below image,
Now the Local Dev One has same file as below image,
Now Local Dev One can see this file using ls command using Git Bash as shown below,
Next, Local Dev One wants to modify this file as per below image,
Also, Local Dev One wants to create 2 new files called MyFile2.cs and MyFile3.cs as shown below,
Content of MyFile2.cs
Content of MyFile3.cs
Now, Local Dev One wants to move these files from local to GitHub repository as shown below,
The list of files
Check the status
Here you can see the modified file name as well as 2 newly created files as shown below,
Here the existing file called MyFile.cs changes is not committed to staging area and the new files called MyFile2.cs and MyFile3.cs are under untracked files means these files are not in Git history. So, I need to add first these new files to staging area but only MyFile2.cs not MyFile3.cs. Finally, I want to commit MyFile.cs and MyFile2.cs files to staging area and push those files to GitHub repository and changed made in MyFile3.cs put in local itself.
Run below commands as shown in image,
If I check the status then see the result as already ready to be committed to staging area and not committed files are shown below,
Then commit those changes to the staging area using command as shown below,
Then push those files from local git to GitHub repository using command as shown below,
Here the command is : git push origin main. The origin here nothing but the alias name of your GitHub repository. Here main is nothing but the default branch name as shown in below image,
In GitHub repository, You can see those committed files are pushed by Local Dev One with added comments as shown below,
So, as per mentioned in flow diagram the Local Dev One is working on multiple repositories and projects. To know which repository the Local Dev One has pushed these changes using command as shown below,
The command is : git remote -v
It shows the GitHub repository name is SatyaTwo.
Here you can see the MyFile.cs content in GitHub repo as shown below,
Here you can see the MyFile2.cs content in GitHub repo as shown below,
Now Local Dev Two wants these changes to his/her workspace using command as shown below,
After successful run above command, Those files are available in Local Dev Two workspace with latest changes as shown below,
Here clone and pull are with single commands but for commit and push we need few steps. Those steps are already described using flow diagram as mentioned above.
SUMMARY
In this write-up, we have learned the below details,
- Understand 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 single repository.
- What is Author identity unknown.
- What is Authorize Git Credential Manager.
****Thank You & Stay Tuned For More****