Exploring Git & GitHub in Depth:
Going Beyond the Basics of Git & GitHub for DevOps.
Table of contents
What is Git & 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 important because it provides access to previous versions of the project. If there is any mistake, we can always roll back or undo the changes without losing any work. GIT is a hero that helps us handle possible problems that may occur while working on a software project.
What is the difference Between Main Branch and Master Branch?
The difference between "main" and "master" is largely contextual and symbolic. "Main" is becoming more widely adopted as a preferred default branch name due to its neutrality and inclusivity, while "master" is still used in some repositories, particularly those that have not transitioned to the "main" convention. It's essential to note that the choice between "main" and "master" is primarily a matter of convention and preference. Both branch names function identically in Git and serve as the primary branch for a repository. Some version control systems, including GitHub, now use "main" as the default branch name for new repositories.
What is the difference between Git and GitHub?
Git is the most popular VCS (version control system) in use today, it is free, open-source, and designed to handle everything from small to very large projects with speed and efficiency. Its flexible architecture means it can be effectively integrated into your workflow. For example, you can use Git to manage all your project's files or just a few files that are important to you.
GitHub is a web-based hosting service for Git repositories. It makes Git more user-friendly and also provides a platform for developers to share code with others. In addition, GitHub makes it easy for others to contribute to projects. GitHub offers both a paid and free subscription. With a free subscription, users can create public repositories. Public repositories are visible to anyone and can be cloned or forked by anyone. (A fork is a separate copy of the Git repository that was made. A clone, in contrast, creates a linked copy that will continue to synchronize with the target repository.) A paid subscription is required to create private repositories. Private repositories are only visible to users who have been given access by the repository owner.
Git is a version control system that allows developers to track changes in their code. GitHub is a web-based hosting service for git repositories. In simple terms, you can use Git without Github, but you cannot use GitHub without Git.
How to create a new repository on GitHub?
These are the 6 simple steps required to create a new repository on GitHub:
Step-1: In the upper-right corner of any page, use the + drop-down menu, and select New Repository.
Step-2: Type a short, memorable name for your repository. For example, "hello-world".
Step-3: Optionally, add a description of your repository. For example, "My first repository on GitHub."
Step-4: Choose repository visibility.
Step-5: Select Initialize this repository with a README.
Step-6: Click Create Repository.
What is the difference between local & remote repositories? How to connect local to remote repositories?
Local repositories are physical, locally-managed repositories into which you can deploy artifacts. Using local repositories, Artifactory gives you a central location to store your internal binaries. Whereas Remote repositories are versions of your project that are hosted on the Internet or network somewhere. Collaborating with others involves managing these remote repositories and pushing and pulling data to and from them when you need to share work.
These are the following steps required to connect local to remote repositories:
First, launch the Git Bash terminal from the “Startup” menu.
Next, move to the local Git repository by utilizing the “cd” command.
Initialize the Git repository through the “git init” command.
To check if any remote repository is connected to the Git local repository, use the “git remote -v” command. Here, the “-v” option is utilized to view the remote connections.
Next, open the GitHub website and click on the repository you want to add to the local repository.
Next, execute the “git remote add <name> <URL>” command. Replace the name with the remote repository name and paste the copied URL here.
Next, fetch the copy of the remote repository through the “git fetch <repository name>” command.
To view the all-remote branches in Git local repository, utilize the “git branch” command along with the “-r” option.