What is Git and why is it important?
Git is a Distributed version control system(DVCS). It is founded by Linus Torvalds in 2005. A DVCS is a type of version control system that allows multiple developers to work on same codebase and track changes to the code over time, even if they are located on different machines.
In DVCS like GIT, each developer has a complete copy of code repo on their local machine, which means they can owner on code even when they are not connected to the internet.
What is difference Between Main Branch and Master Branch??
-
What is the difference Between Main Branch and Master Branch??
In the context of version control systems like Git, "Master Branch" and "Main Branch" are two commonly used names for the default branch of a repository.
Traditionally, the default name for this branch in Git was "master," but due to concerns about the potential racist connotations of the word "master," some organizations have started using "main" as an alternative.
In terms of functionality, both the "master" and "main" branches serve the same purpose: they are the default branch that is checked out and used when a new clone or checkout is performed on the repository. Changes made to this branch are typically considered to be the latest stable version of the codebase.
Overall, the difference between "Master Branch" and "Main Branch" is primarily one of naming convention, and the choice of which term to use is up to the individual or organization managing the repository.
Can you explain the difference between Git and GitHub?
Git is a version control system that allows developers to track changes in their codebase over time. It provides a set of commands that enable developers to create, review, and merge code changes to their projects.
On the other hand, GitHub is a web-based platform that provides hosting services for Git repositories. It allows developers to store and manage their Git repositories in the cloud, collaborate with other developers, and contribute to open-source projects.
In simple terms, Git is the tool that developers use to manage and track changes in their code, while GitHub is a platform that allows developers to store and share their Git repositories with others. Think of Git as a hammer and GitHub as a tool belt that holds the hammer and other tools.
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 "+" sign in the top right corner of the screen.
Select "New repository" from the dropdown menu.
On the "Create a new repository" page, enter a name for your repository.
Optionally, enter a description for your repository.
Choose whether you want your repository to be public or private.
Select the "Initialize this repository with a README" option if you want to add a README file to your repository.
Optionally, choose a .gitignore file and a license for your repository.
Click the "Create repository" button.
Your new repository will now be created on GitHub, and you'll be taken to the repository page where you can start adding files, making changes, and collaborating with others.
What is the difference between local & remote repositories? How to connect local to remote?
A local repository is a Git repository that is stored on your local machine, while a remote repository is a Git repository that is stored on a remote server, such as GitHub, GitLab, or Bitbucket.
The main difference between local and remote repositories is that local repositories are used for making changes to the code and tracking changes, while remote repositories are used for sharing and collaborating on code with others.
To connect your local repository to a remote repository, you need to follow these steps:
Create a new repository on your remote server (e.g., GitHub).
Copy the URL of the remote repository.
Open your local Git repository using the command line or a Git GUI tool.
Type the following command in the terminal or console to connect your local repository to the remote repository:
git remote add origin <remote_repository_URL>
Here, "origin" is the name of the remote repository and "<remote_repository_URL>" is the URL of the remote repository that you copied earlier.
Tasks
Set your user name and email address, which will be associated with your commits.
- Create a repository named "Devops" on GitHub
- Connect your local repository to the repository on GitHub.
4 .Create a new file in Devops/Git/Day-02.txt & add some content to it
Push your local commits to the repository on GitHub
Here you can see the file Day-02.txt in the central repository.