1.What is Git and why is it important?
Git is a DevOps tool used for source code management. It is a free and open-source version control system used to handle small to very large projects efficiently. Git is used to track changes in the source code, enabling multiple developers to work together on non-linear development.
Git is a version control system used for tracking changes in the source code. The distributed version control tool is used for source code management. It supports non-linear development through its thousands of parallel branches
It is a free and open-source tool
It tracks history and creates a backup
Branching is easier
Multiple people collaborate on a project and keep track of the changes made to the code over time
easier to revert to an earlier version of the code if a mistake is made or if you need to return to a previous state
2. What is the difference Between Main Branch and Master Branch?
By default, GitHub uses the term “master” for the primary version of a source code repository. Developers make copies of the “master” on their computers into which they add their code, and then merge the changes back into the “master” repo.
Github changed the “master” to “main” as part of the company’s effort to remove unnecessary references to slavery and replace them with more inclusive terms
So, bottom line they wanted to get rid of the unpleasant term “master”. Technically it's still the same though
3.Can you explain the difference between Git and GitHub?
Git is a DevOps tool used for source code management. It is a free and open-source version control system used to handle small to very large projects efficiently. Git is used to track changes in the source code.
GitHub is a web-based platform that provides hosting for version control using Git.GitHub is a very popular platform for developers to share and collaborate on projects, and it is also used for hosting open-source projects.
4.How do you create a new repository on GitHub?
Go to the GitHub website and log in to your account.
Click the “+” icon in the top right corner of the screen and select “New repository”.
Enter a name for your repository
Add a description of your repository in the “Description” field.
Select whether you want your repository to be public or private.
Choose a license for your repository.
Click the “Create repository” button.
5.What is the difference between local & remote repositories? How to connect local to remote?
The local repository is a Git repository that is stored on your computer.
The remote repository is a Git repository that is stored on some remote computer. The remote repository is usually used by teams as a central repository into which everyone pushes the changes from his local repository
To connect local to the remote repository
Initialize the git repository using #git init in the local repository
Create a repository on the GitHub account
In your local repository, run the following command to add the remote repository
git remote add origin <remote repo url>
<remote repository URL> → Copied URL of the remote repository.
- Using #git remote -v, we can check whether the local repository is connected to the remote repository or not
Tasks:
Task-1:
Set your user name and email address, which will be associated with your commits.
To set a user name and email address to be associated with commits in Git, use the following commands, replacing the user name and email address with your own:
git config --global user.name "Your Name"
git config --global user.email "youremail@gmail.com"
Task-2:
Create a repository named "Devops" on GitHub
Connect your local repository to the repository on GitHub.
git clone <repo https url>
Create a new file in Devops/Day-09.txt & add some content to it
Push your local commits to the repository on GitHub
-