Deep Dive In Git And Githubπͺ
We have already seen the basics of Git and Github. Now we will look at some important concepts about it.
π Difference between Main Branch and Master Branch?
The difference between the "Main" branch and the "Master" branch is in their names and historical context in version control systems like Git. In the past, "Master" was commonly used as the default branch where main development work took place. However, to promote more inclusive language, many platforms and communities have shifted towards using "Main" instead of "Master."
Both "Main" and "Master" branches serve the same purpose: they are the primary branches where developers collaborate, and the latest stable code is maintained. The choice between the names depends on the preferences and conventions of the development team or organization. Nowadays, "Main" is gaining popularity as the default branch name, reflecting the industry's efforts to adopt more diverse and inclusive practices. ππ
π€ Difference between Git and GitHub?
Let's see the difference between Git and GitHub in simple terms:
Git π: Git is like a magic time machine for developers. It helps them keep track of changes they make to their code while they are working on a project. So, imagine you are writing a story, and you want to save different versions of it at different stages. Git allows developers to do just that for their code. It helps them save snapshots of their code at different points in time. This way, if something goes wrong or if they want to see how their code looked before, they can easily go back to any previous version. Git is a tool that works on your own computer, and it doesn't need the internet to do its magic!
GitHub π: Now, imagine you want to share your story with your friends and work on it together. GitHub is like a cool website where you can upload your story and invite your friends to read, edit, and add their own parts to it. It's a platform that uses Git's magic to store your code and make it accessible online. So, instead of keeping your code only on your computer, you can save it on GitHub and collaborate with others. It's like having a virtual writing club where everyone can contribute to the story and work together.
π How do you create a new repository on GitHub?
Let's get started by creating a new repository on GitHub, where we'll keep and organize our code. Follow these simple steps:
Open your web browser and visit github.com.
Log in to your GitHub account.
On the GitHub homepage, click the "+" button at the top-right corner, then select "New repository" from the menu.
Give your repository a meaningful name.
You can also add a description to give more details about your repository.
Choose whether you want the repository to be public or private, depending on your needs.
π Difference between a local and a remote repository?
Local Repository π : A local repository is a copy of your project that is stored on your computer. It contains all the files, code, and version history of your project. When you work on your project, you make changes to the files in your local repository. Git tracks these changes and allows you to save snapshots of your code at different points in time. This way, you can go back to previous versions if needed or see the history of your project.
Remote Repository π: A remote repository is a copy of your project that is stored on a server or an online platform like GitHub, GitLab, or Bitbucket. It serves as central storage for your project, where you can share your code with others and collaborate with a team. When you want to share your code or collaborate with others, you push your local changes to the remote repository. This way, others can see your changes, contribute their changes, and work together on the project. Remote repositories make it easy for developers to collaborate on projects and keep the code in a secure and centralized location.
π How to connect local to remote?
To link your local repository with a remote repository on GitHub, adhere to the following steps:
Create a new repository on GitHub, as described earlier.
On your local computer, locate the directory that houses your Git repository using either the command line or a Git client.
Integrate the URL of the remote repository into your local repository by executing the command:
git remote add origin <remote_repository_url>
Replace
<remote_repository_url>
with the URL of your remote repository on GitHub.Verify the connection between your local and remote repositories using the command:
git remote -v
This will display the remote repository URL associated with your local repository.
Thanks for being till the end of the blog. I hope that this blog helps you to understand some of the advanced concepts about Git and Github.
Subscribe to my newsletter
Read articles from Nitish Chintakindi directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Nitish Chintakindi
Nitish Chintakindi
Learning DevOps Tools and Technologies π€ Looking forward to help and collaboration with Community Building, Code Projects & Open Source. Join me on this thrilling DevOps journey as we embrace innovation, automation, and a brighter future for software developmentπ Let's build a seamless digital world togetherππ»