This is my 2nd blog on Git and Github. You can refer to my 1st blog here π.
In this blog, we will understand what is
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 the local repo to the remote repo?
QnA
What is Git and why is it important?
Git is a distributed version control system, created by Linus Torvalds who is also the creator of Linux.
The use of Git is important as it tracks the changes in computer files. Git uses in software development where developers are working on source code collaboratively.
What is the difference Between Main Branch and Master Branch?
There is no difference between the Main branch and the Master branch other than their name.
Initially, the default branch in git is the master branch, however, for GitHub company in the US there were some issues and to counter that they have to change the name of the default branch from master to main.
We can change the default branch name in the setting on the GitHub website.
Can you explain the difference between Git and GitHub?
Git is distributed version control system which is a tool for computers.
GitHub is an online platform for storing Git files and collaborating with others online.
How do you create a new repository on GitHub?
To create a new repository,
Visit https://github.com/new
Enter the repository name and description
Choose whether you want it to be public or private
Click on create repository button
You have successfully created your new repository on GitHub.
What is the difference between local & remote repositories?
How to connect the local repo to the remote repo?
Local repositories are stored on a computer only whereas remote repositories are stored on online git providers' platforms some of the famous websites are GitHub, Bitbucket, and GitLab.
To connect the local repo to the remote repository follow the steps:
Use the
git remote add
command to add the repo to git.git remote add origin https://github.com/neelsoni26/Devops-Day08-Challenge.git
Verify with
-v
:git remote -v
The repository is connected, now we can use fetch, push and pull commands.
For more, you can refer to my blog on Create, Push, Pull Repo in GitHubπ
Tasks-1
Set your user name and email address, which will be associated with your commits.
There are two ways to set a username and email for your commits.
Global
Repository-Specific
To set your global username/email configuration:
Open the terminal.
Enter your username:
git config --global user.name "user name"
Enter your email address:
git config --global user.email "example@example.com"
To set repository-specific username/email configuration:
In the terminal, change to the repository directory.
Set your username:
git config user.name "user name"
Set your email address:
git config user.email "example@example.com"
Verify changes:
cat .git/config
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
Create a repository named "Devops" on GitHub
Connect your local repository to the repository on GitHub.
Ceate a new file in Devops/Git/Day-02.txt & add some content to it
Push your local commits to the repository on GitHub
If you like the post do like, have any queries? do comment and share the blog π