Day9: Devops Journey
Deep Dive in Git & GitHub for DevOps Engineers.
What is Git and why is it important?
It is a DevOps tool used for source code management. The main purpose of Git is to manage different versions of a project, which could be source code, documents, large data sets, or anything else you wish to track. It allows multiple people to work on a project simultaneously, without overwriting each other's changes
Why it is important:
Version control & collaboration
Backup & Restore
Branching & Merging
Staging Area
Distributed System
Speed & it is open source.
What is difference Between Main Branch and Master Branch??
The "main" and "master" branches have the same purpose: they both represent the default branch of a repository. The term "master" has traditionally been used as the default branch in Git. Later it become "main" as the default branch name instead.there isn't a functional difference between "main" and "master" branch. The difference lies primarily in the naming convention.
Can you explain the difference between Git and GitHub?
Git is a version control system that allows the developer to track their code while GitHub is a web-based graphical interface that hosting service for git repository.
Git is a software while GitHub is a service.
Git is maintained by Linux while Github is maintained by Microsoft.
Git is a command-line tool while Github provides a graphical interface.
Git has no user while Github has a built-in user.
Git is installed locally on the system while GitHub is hosted on the web.
How do you create a new repository on GitHub?
Sign in to your GitHub account.
Click on the '+' icon at the top right corner of your GitHub homepage. From the dropdown menu, select 'New repository'.
You'll be directed to a new page - Here fill the details include repo name, description ,visibility etc.
Create repository at the bottom of page.
What is difference between local & remote repository? How to connect local to remote?
Local repository:
A local repository is present on your local machine.
It contains all the files, commits, branches, and history of your project.
We have direct access to it, and we can work on our project without an internet connection.
If we make any changes to files in the local repository. It can be tracked and committed locally.
Remote repository:
A remote repository is hosted on a server like GitHub or GitLab.
It is a central location where multiple developers can collaborate on a project.
It provides us backup of code and allows us to easily share and collaborate.
It allows team members to access the latest changes made by others and to contribute to their changes.
Task-1: Set your user name and email address, which will be associated with your commits.
git config --global
user.name
"GitHub username"
git config --global
user.email
"Github email"
task-2:
Create a repository named "Devops" on GitHub
Connect your local repository to the repository on GitHub.
Create a new file in Devops/Git/Day-02.txt & add some content to it
Push your local commits to the repository on GitHub
Step 1: Open the GitHub account and create a Git repository named DevOps.
Connect your local repository to the repository on GitHub.
Push your local commits to the repository on GitHub.
#git init
#mkdir git
#vim day2.txt
xyz......
#cd git
#git add .
#git status
#git branch -M main - change branch to main from master
#git commit -m "made some changes in file"
#git branch -M main - change branch to main from master
Create token for authentication:
Github > profiles > settings > Developer settings > personal access tokens > classic token > generate a personal token > set expiry date > select scopes > create token > copy & paste on notepad for later use.
#git push -u origin main
Verification:
Thank you for reading my blog:)