Day 9 Task: Deep Dive in Git & GitHub for DevOps Engineers.
1.What is Git and why is it important?
Git is a distributed version control system that allows developers to track changes to their code and collaborate with others.
Git is important for several reasons:
Version Control: Git allows developers to track changes to their code, revert to previous versions if needed, and collaborate with others.
Branching: Git's branching model allows developers to work on separate features or fixes without affecting the main codebase, enabling parallel development.
Collaboration: Git enables multiple developers to work on the same project simultaneously, merging their changes efficiently.
Code Review: Git facilitates code review processes, where changes can be reviewed before merging into the main codebase, ensuring code quality.
Deployment: Git is often used in CI/CD pipelines to automate the deployment process, ensuring that only tested and approved changes are deployed to production.
2.What is difference Between Main Branch and Master Branch?
The “master” branch typically represents the main development branch, where the latest changes and features are integrated before being released or merged into other branches.
“main” is a commonly used alternative to “master” as the default branch name. It aims to promote diversity and inclusion within the software development community.
The “main” branch serves the same purpose as the “master” branch, representing the primary branch for development, integration, and the latest changes.
3.Can you explain the difference between Git and GitHub?
Git: A powerful tool for version control, handling the local storage, tracking, and management of codebase changes.
GitHub: A web-based platform that provides hosting services for Git repositories. It offers additional features like collaboration tools, issue tracking, and code review functionalities.
4.How do you create a new repository on GitHub?
To create a new repository on GitHub, follow these steps:
Log in to your GitHub account.
Click on the "+" icon in the top right corner and select "New repository."
Enter a name for your repository, select the visibility (public or private), and add a description if desired.
Click "Create repository."
5.What is difference between local & remote repository? How to connect local to remote?
Local repository: A copy of the entire project history stored on your computer. You can work on it even when offline.
Remote repository: The online version of your project hosted on GitHub or another platform. It serves as a central location for collaboration and sharing
To connect a local repository to a remote repository on GitHub, you can follow these steps:
a. Set your user name and email address in Git:
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
b. Create a new repository on GitHub.
c. In your local repository, add the remote repository URL as a remote:
git remote add origin <repository_url>
d.Push your local commits to the remote repository:
git push origin main
task-1:
Set your user name and email address, which will be associated with your commits.
git config --global user.name "<your username>"
git config --global user.email "<your email>"
task-2:
1.Create a repository named "Devops" on GitHub
-
- 2.Connect your local repository to the repository on GitHub.
1. Add the remote repository URL:
Use the git remote add command to associate your local repository with the remote repository on GitHub:
git remote add origin <repository_url>
For example:
2. Verify the remote:
Use the git remote -v command to verify that the remote has been added correctly:
-
This command will display information about the remote repository, including its name and URL.
With these steps, your local repository is now connected to the remote repository on GitHub, allowing you to push your local changes and fetch updates from the remote repository in the future.
3.Create a new file in Devops/Git/Day-02.txt & add some content to it
4.Push your local commits to the repository on GitHub