Day12 of #90DaysOfDevOps
Deep Dive in Git & GitHub for DevOps Engineers
Hi there! I'm Anuj Tomar, an enthusiastic and aspiring DevOps engineer and Cloud engineer with a passion for integrating development and operations to create seamless, efficient, and automated workflows. I'm driven by the challenges of modern software development and am dedicated to continuous learning and improvement in the DevOps field.
What is Git and why is it important?
Git is a powerful version control system. Think of it as a tool that helps you keep track of changes you make to files over time. Imagine you’re writing a book and you want to save every version of it, so you can always go back to any previous version whenever you want. Git does exactly that but for code and any other type of file.
What is the difference between Main Branch and Master Branch?
The default branch created locally in git is known as "master", while the default branch created in GitHub is known as "main".
Historically, the primary or the default branch for Git versions was named as "master".
Explain the difference between Git and GitHub?
Git:- Git is Command-Line Interface tool (CLI). It is free, open-source and Distributed Version Control System (DVCS), that tracks the changes in any set of file.
GitHub:- GitHub is Graphical User Interface tool (GUI). GitHub is a web-based hosting service for git repositories. GitHub is more user-friendly, repositories are open here so that developers can contribute to one another's code.
How do you create a new repository on GitHub?
Sign in to GitHub: Open your web browser and go to GitHub. Sign in to your GitHub account.
Go to Your Profile: Click on your profile icon at the top right corner of the screen and select
Your repositoriesfrom the dropdown menu.Create a New Repository: On the
Your repositoriespage, click the greenNewbutton on the right-hand side.
Fill in Repository Details:
Enter a name for your repository in the
Repository namefield.Optionally, add a description to describe your project.
Choose between making the repository public or private.
Select Initialize this repository with a README if you want to start with a README file.
What is the difference between a local & remote repository? How to connect local to remote?
Local repository: A local repository is a copy of the entire project’s history and codebase that resides on a developer’s machine. It allows developers to work offline, experiment with different ideas, and maintain a private workflow.
Remote Repository: A remote repository is a central shared repository hosted on a server, typically accessible over the internet. Examples are GitHub, GitLab, or Bitbucket.
Connect your local repository to remote repository
Make a repository on GitHub (remote) as we made above
Initialize an empty git repository:
To connect your local repository to a remote repository, first create a repository on GitHub (remote) as described above. Then, initialize an empty Git repository on your local machine by using the following command:
git init
Add the remote repository URL:
git remote add origin <remote_repo_URL>
- Push to remote:
git push origin main
Tasks
Task 1:
Set your user name and email address, which will be associated with your commits.

Task 2:
Create a repository named "DevOps" on GitHub.

Connect your local repository to the repository on GitHub.
git remote add origin <remote_repo_URL> git remote -v
Create a new file in Devops/Git/Day-02.txt add some content to the file.

Push your local commits to the repository on GitHub.
To push your local commits to the repository on GitHub, follow these steps:
Open your terminal and navigate to the local repository directory.
Add changes to the staging area (if not already done):
git add .Commit your changes with a message:
git commit -m "Your commit message"Push your commits to the remote repository on GitHub:
git push origin mainReplace
mainwith the name of your branch if it's different.
Make sure you have already connected your local repository to the remote repository on GitHub using the git remote add origin <repository-url> command.
Stay tuned for more updates on my DevOps journey! 📅
Feel free to reach out to me if you have any questions or need any more help. Let’s connect, learn, and succeed together!
Happy Learning!😊

