Table of contents
- What is Git and why is it important?
- What is the difference between Main Branch and Master Branch?
- Can you explain the difference between Git and GitHub?
- How do you create a new repository on GitHub?
- What is the difference between local & remote repositories? How to connect local to remote?
- Task 1: Set your user name and email address, which will be associated with your commits.
- Task 2: Create a repository on GitHub and connect your local repository to the repository on GitHub.
- Task 3: Create a new file & add some content to it and push your local commits to the repository on GitHub.
- Thanks for reading!
What is Git and why is it important?
Git is a distributed version control system (DVCS) that is widely used in software development and other collaborative projects. It was created by Linus Torvalds in 2005 and has since become one of the most popular and essential tools for managing source code and tracking changes in software development.
Git is a Version Control System that helps us to keep track of all the changes in the codes or files we create, along with the author of each change. This can help to debug the code or go back to some previous version in case of errors. With the help of Git, we can work on and push the files from anywhere to a single repository. We can also work on different features of an application using branches. For all these reasons, Git is important and helpful.
What is the difference between Main Branch and Master Branch?
The terms "Main branch" and "Master branch" refer to the default branch in a Git repository where the main development work takes place. The difference between them lies mainly in the evolution of terminology and the acknowledgment of harmful historical connotations.
Before October 2022, when we used to create a new repository in Github, the name of the default branch was created as master. But now, the default branch name is created as main.
Can you explain the difference between Git and GitHub?
Git is a version control system that lets you manage and keep track of your source code. Github is UI based service to help in managing your Git repositories.
Git: Git is a distributed version control system (DVCS) that was created by Linus Torvalds in 2005. It is a tool used to manage and track changes in source code and other text-based files. Git allows multiple developers to work collaboratively on a project, keeping track of the entire history of changes made to the codebase.
GitHub: GitHub is a web-based platform and hosting service that provides a graphical user interface (GUI) and collaboration features built around Git. It was founded in 2008 and quickly became one of the most popular code-hosting platforms and social coding communities.
How do you create a new repository on GitHub?
To create a repo on GitHub, we need to have an account, then click on "New" add a name and Click on "Create Repository" after entering all the details.
New Repository has been created.
What is the difference between local & remote repositories? How to connect local to remote?
A remote repository is present on GitHub where anyone can contribute if it is public.
A local repository is when only you have access to it and it is only in your system.
To connect a local repo to your remote repo - git remote add origin <remote repository URL>.
Keep on reading to know how to connect the local repo with the remote repo.
Task 1: Set your user name and email address, which will be associated with your commits.
git config --global
user.name
"Your name"
will set your name.
git config --global
user.email
“
yourmail@gmail.com
will set your email address.
Task 2: Create a repository on GitHub and connect your local repository to the repository on GitHub.
To connect your local repo to your remote repo -
git init
- Initializes that folder as git by creating a .git folder.git remote add origin repo_url
- To specify the remote repo with which you want to connect your local repo.git remote -v
- To verify the connection.git pull origin branch_name
- To pull the data from the remote repo to the local repo.
Task 3: Create a new file & add some content to it and push your local commits to the repository on GitHub.
Create a file.
Do the following steps on it:
git status
- to check if the file is added and committed or not.git add file.txt
- to add a file in the staging area.git commit -m "msg"
- To commit a file with any message.To push the committed code to your remote repo -
git push origin branchname
.
Let's push this code to our GitHub repo using the command git push origin main.
So today, we got to know the difference between Git and GitHub, the main branch and master branch, how to commit your latest changes and how to connect your local repo to your remote repo.
Thanks for reading!
#devops#90DaysOfDevops#TrainWithShubham
Let's connect on Linkedin - linkedin.com/in/namya-khullar-7b5758200