What is Git and why is it important?
Git is a version control system used to save different versions of code. You can use Git to track changes you make to your code over time, allowing you to revert to earlier versions if needed. When you feel that your code is in a good state, you can commit your changes, which creates a snapshot of the current version of the code.
Git is an important tool for software development, as it allows multiple people to work on the same codebase without interfering with each other's work, and it helps to keep track of changes made over time."
What is the difference Between Main Branch and Master Branch?
There is no difference both are the same, the terms "main branch" and "master branch" refer to the default branch in a Git repository, which is the branch that is created when a repository is initialized.
In the past, the term "master branch" was commonly used to refer to the default branch, but in recent years there has been a movement to change this terminology due to its association with slavery and oppression.
Can you explain the difference between Git and GitHub?
Git is the actual version control system that tracks changes to code, while GitHub is a web-based platform that hosts Git repositories and provides a user interface for developers to manage their repositories and collaborate with others.
How do you create a new repository on GitHub?
Go to GitHub,> Select "New repository" from the dropdown menu.
give your repository a name and a short description. > Choose whether you want the repository to be public or private > Select "Initialize this repository with a README" if you want to create a README file for your repository
> Choose the license you want to use for your repository. If you're not sure which license to use, you can click on "Choose a license template" for more information > Click on "Create repository" to create your new repository.
What is the difference between local & remote repositories? How to connect local to remote.
A local repository is available on your local instance or computer, which means you can access it without an internet connection.On the other hand, a remote repository is stored on a web-based server and can only be accessed through the Internet. A repository is a storage folder that stores versions of your work or code.
To connect your local repository to a remote one, you first need to create a repository on a web-based service like GitHub, and then copy the remote repository URL. Next, open the command-line interface (CLI) on your local computer and use the following command to add the URL to your local repository:
git remote add origin <remote repo URL>
After adding the URL, you can push your changes to the remote repository using the appropriate command
Umm… Okay…I will give an example for a better understanding of git.
\>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
Imagine you are a chef in a restaurant, and you are responsible for creating a new dish. You start by making a recipe card that lists all of the ingredients and the steps required to make the dish. As you work on the recipe, you make changes to the recipe card to improve the flavor and presentation of the dish.
However, you realize that you made a mistake in one of the steps, and the dish did not turn out as expected.
Fortunately, you saved earlier versions of the recipe card, so you are able to go back to a previous version of the recipe and make the necessary changes. This is similar to how Git works – it allows you to save different versions of your code so that you can go back to an earlier version if needed.
As you continue to work on the recipe, you collaborate with other chefs in the restaurant who have their own ideas for how to improve the dish. You create a shared folder where everyone can access and edit the recipe card, and Git allows you to keep track of who made what changes and when. This helps to avoid conflicts and ensures that everyone is working with the most up-to-date version of the recipe.
Finally, when you are happy with the dish and want to add it to the restaurant menu, you commit the final version of the recipe card. This creates a snapshot of the code at that point in time, and allows you to easily access and reproduce that version of the recipe in the future.
<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
Tasks:
1.Set your user name and email address, which will be associated with your commits.
To set the global user name and email for Git, you can use the git config command with the --global option to apply the settings globally across all repositories on your machine.
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
2. Create a repository named "Devops" on GitHub.
-
3.Connect your local repository to the repository on GitHub.To add the GitHub to Local Machin use the Github Repository URL.
if want to check wether is add or not you can "git remote -v" command.
4.Create a new file in Devops/Git/Day-02.txt & add some content to it
5.Push your local commits to the repository on GitHub
Before pushing we need to add the and commit in local.
then
***************************************************************************
Thank you so much for taking the time to read my day-9 blog. I really appreciate it! If you have any suggestions or corrections, please feel free to leave a comment. Your feedback will help me to improve my writing and make future blog posts even better.
I am always looking to improve and learn more, so any constructive criticism or feedback is greatly welcomed and appreciated. Your input can also help me to identify areas where I need to focus more on in my writing.
Once again, thank you for reading my blog post and I hope you found it informative and engaging. Stay tuned for more exciting content in the future!