What is Git and why is it important?
Git is a DevOps tool used for source code management. It is an important tool for the version control of the project. It is used for tracking changes in the source code, over time, and collaborating with others on a project. It helps in fixing the error by going back to the previous version to solve the problem.
What is the difference Between the Main Branch and the Master Branch?
The main branch and Master branch both are the same. No functional difference between the "main" and "master" branches. "Main" is the new default for everyone. The old name "master" could be hurtful to some people because of its historical meaning. We are moving to 'Main' because it's more welcoming and respectful to everyone."
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 hosting service for git repositrory.
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.
What is the difference between local & remote repositories? How to connect local to remote?
Local and remote repositories are both essential parts of version control systems like Git.
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.
To connect a local repository to a remote repository.
Task-1: Set your user name and email address, which will be associated with your commits.
Open the terminal and log in to your GitHub account using the following commands.
git config --global user.name "GitHub username"
git config --global user.email "Github email"
In place of "GitHub username " give the username of your GitHub account and in place of "GitHub email " give your GitHub email ID.
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.
To create the repository you have to log in to your GitHub account and in the top right corner, there is a "+" sign. By clicking on the icon, select Create a new repository and after that, it opens an interface for creating a repo in which you have to keep your repo name, and in the last click on the Create Repository.
Step 2: Connect the local repository to Github.
Step 3: Create a new file and add some content to it
Step 4: Now commit that text file to GitHub.
Here is our committed file in our repo.
Summary:
In this blog, we learn about git and why it is important. We also see the difference between the main and the master and local and remote repositories. In the last, we do two hands-on practice questions where we connect the local repository to the remote repository.