Table of contents
- Day9 - #90daysdevopschallenge
- What is Git and why is it important?
- What is the difference Between the Main Branch & the 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 named "Devops" on GitHub
- Task 3: Connect your local repository to the repository on GitHub.
- Task 4: Push your local commits to the repository on GitHub
Day9 - #90daysdevopschallenge
In my previous blog, I already discussed Git & Github basics and also discussed why it came into the picture. if you don't go through that I suggest you first go with Git & GitHub Basics
What is Git and why is it important?
Git is a distributed version control system, that allows developers to manage or track changes in the code and multiple people can work on different parts of a project simultaneously. It's so helpful to manage large and complex projects in a large team. you can install in your system.
What is the difference Between the Main Branch & the Master Branch?
Both are the same. It depends on the developer's thinking some people call master or some call it main. It's a default branch in Git.
Original code or stable code is present inside this folder. There is a safe zone, If you want to make any code changes first create a feature branch then make changes and merge into the main branch.
The main benefit is, that if you want to revert all the changes then you can.
Can you explain the difference between Git and GitHub?
Git | GitHub |
Git is a distributed version control system. | GitHub is a web-based service for the Git repository. |
Git is a free and open source software or tool, you can install in your system. | GitHub is a service by using this you can manage your large and complex repository. |
Git allows developers to track changes to their code over time. | GitHub provides a platform for storing, sharing, and collaborating on Git repositories |
Git does not require an internet connection. | GitHub requires an internet connection for hosting and accessing repositories. |
How do you create a new repository on GitHub?
Step 1: Log in to your GitHub account. Go to the home page of your account. Step 2: Click on the new option.
Step 3: Give a name to the repository.
Step 4: You can give "Description" to your repository. but it's not required.
Step 5: You can select the repository to be either Public or Private.
Step 6: If you want to initialize this repository, Select the checkbox for 'Add a README file'.
Step 7: Click on the "Create Repository" option.
Congratulations! Your new repository is created now.
What is the difference between local & remote repositories? How to connect local to remote?
A local repository is a repository that is present inside the local system of a developer but a remote repository is stored on a remote server, platforms like Github, Gitlab, and Bitbucket.
for connecting local to the remote repository:
Step 1: Create a remote repository "repo1" on GitHub.
Step 2: In your local repository, add the URL of the remote repository 'repo1' as a new remote by using the command:
git remote add <reponame> <URL of remote repository>
Step 3: Now you can push the changes in your remote repository from your local repository
git push -u <remoterepo_name>
Task 1: Set your user name and email address, which will be associated with your commits.
To set your user name and email address we used the git command:
git config --global
user. name
"username"
git config --global
user.email
"
user_email@example.com
"
Task 2: Create a repository named "Devops" on GitHub
Task 3: Connect your local repository to the repository on GitHub.
git config --global init.default branch main
git remote add DevOps
https://github.com/DevUnnati/DevOps.git
Task 4: Push your local commits to the repository on GitHub
git clone <URL of your repository>
Create a new file inside the repository "test.txt".
git add <file_name>
git commit -m "<message>"
git push -u origin main
Note: If you are facing any problems pushing your code into the repository you can check on my previous blog Git & GitHub Basic, already explained in detail.
In The Next Article will discuss Advanced Concepts of Git & Github...
Thank you for giving your precious time to read this blog/article and if any suggestions or improvements are required on my blogs feel free to connect on Linkedin Unnati Gupta.