Day8&9 #90DaysOfDevOps Challenge
Aishwarya keshri
Azure DevOps Support Engineer at Microsoft || MS Certified - AZ900 || Ex-Onclusive || NIT Raipur
?Version Control system:
The version control system helps us keep track of our changes by storing all the version history.
There are two types of VCS-
1. Centralised VCS - Where the work is done directly in a remote repository. To check in the changes and share them with the team, one has to connect to the internet. Ex. TFVC, Subversion, etc.
2. Distributed VCS - Where we have a remote repository at the centralized location as well as a copy of it can be stored in every user's Local machine which is called a local repository. Users can commit changes locally and push them to the remote side all at once, by connecting to the internet. Ex. GitHub, Azure Repos Git, GitLab, etc.
?What is Git:
Git is an open-source distributed version control system, which is used to store our source code, and helps in keeping track of our history of changes by storing all the versions of our files.
It was created by Linus Torvalds in 2005 for the development of the Linux kernel and has since become one of the most widely used version control systems for software development.
Why Git is important:
Git is an essential tool for developers, some of the reasons are as below -
version control - It helps them to keep track of their history of changes and check the previous versions whenever required.
Collaborate - It makes it easy for all the team members to clone a copy in their local machine and contribute according to the assigned task then send their changes to the main code base. It also provides a tool for reviewing changes and resolving conflicts when multiple developers are working on the code.
Branching and Merging - It allows developers to create multiple branches to isolate different stages like dev, release, hotfix, etc. as well as their work to avoid conflicts with others. Once the work is done on a branch it can be merged with other branches. There are many ways of merging the code, which gives more control over the history of the codebase and how you want to share your changes with others.
Backup and Recovery - By storing code and its history in a repository, developers can easily recover previous versions of their code if something goes wrong.
?Difference between Git and GitHub:
?Difference between the Master branch and Main Branch in Git:
In git Master and the main branch refer to the same branch. Initially, the default branch was named Master but over the period some people raised a concern about the name Master due to its association with 'Slavery'. In response, the Git project decided to rename the default branch to "main" starting with Git version 2.28.0. So now the default branch name is "Main".
The purpose of this branch is to be the main branch of development and to have the latest stable version of the code.
?Difference between Remote and Local repo:
?Connect local repo to remote repo:
If we have initialized a repository locally and want to connect it to our existing remote repo, we can use the below steps-
git init
2. Add a remote repo as the origin -
git remote add origin <remote repo URL>
3. Check the remote repo for this local repo -
git remote -v
?Git Configuration settings:
There are 3 types of git configurations-
System Git configuration file settings apply to all users and repos on your computer.
Git config --list --system
Global Git configuration file settings apply to the current user and their repos.
File location - C:\Users\\.gitconfig
Git config --list --global
Local Git configuration file settings apply to a local repo. To view those settings, run the following command in the root folder of a repo.
File location - .git directory: .git/config
git config --list --local
You can tell Git to prune remote branches during every fetch to remove stale remote-tracking branches in your local repo that no longer exist on the corresponding remote repo.
领英推荐
git config --global fetch.prune true
?Tasks:
Task-1:
Task-2:
?Steps:
To install git on your machine, follow the official link. I already have git installed on my machine.
git init
3. Configured git to use my username and email address.
4. Create a new GitHub repo -
5. Created a new file in the local git workspace -
6. commit this change to the local repo -
It shows if the changes are staged or not.
Red - unstaged (untracked by git)
Green - staged (tracked by git)
git status
To stage all the changes in the working space.
Git add .
To commit the changes.
Git commit -m "commit message"
7. Now to push this commit to our existing repo in GitHub, we need to add the GitHub repo as a remote repo in our local. To connect the local repo to the GitHub repo -
git remote add origin <Remote_URL>
Remote_URL = clone URL from GitHub
To check the current remote repo -
git remote -v
8. Now push the changes to the remote GitHub repo -
git push origin master
The changes are pushed successfully. ??
Thank you for reading! ??