Contents:
What is Git and why is it important?
What is 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 difference between local & remote repository? How to connect local to remote?
What is Git and why is it important?
Git is:
History Keeper: It remembers every change you make in your code.
Team Player: Helps many coders work on the same project without messing things up.
Backup Guru: Keeps a copy of your code in case something goes wrong.
Why it's important:
Team Harmony: Makes teamwork smooth and happy.
Time Travel: Let you go back in time if you make a mistake
Safe Coding: Protects your code like a superhero shield.
What is the difference between the Main Branch and the Master Branch?
In simple words, the difference between the "main" branch and the "master" branch in Git mostly comes down to the name and the convention around its use.
Master Branch: Historically, the default branch name in Git was "master." It was the primary or default branch where the stable version of the project lived. All the major development work would eventually merge into this branch.
Main Branch: In recent years, there's been a shift towards using "main" as the default branch name instead of "master" due to the negative associations with the term "master." GitHub, GitLab, and other platforms and communities have started adopting "main" as the default to promote a more inclusive environment.
Explain the difference between Git and GitHub
Git is like a toolbox:It's the tool you use on your computer for version control.
GitHub is like a workshop:It's the online platform where your code and the Git can mingle with other developers.
How do you create a new repository on GitHub?
Go to GitHub:
Sign In:
Create a New Repository :
- Click on the "+" sign in the top right corner and select "New repository."
Fill in Repository Details ๐:
Give your repository a name. ๐
Add a description (Optional).
Choose public or private (public means others can see your tree). ๐๐
Initialize with a README if you want to start your repository with a little welcome note (Optional). ๐๐
Create Repository:
- Click the "Create repository" button
What is the difference between local & remote repositories? How to connect local to remote?
Local Repository: A local repository is on your own computer. It's your personal copy of a project where you can make changes, commit them.
Remote Repository: A remote repository is hosted on the internet or a network where your code lives and collaborates with others.
Initialize Git in Your Local Project: ๐ก
Open your terminal or command prompt.
Navigate to your local project folder using the
cd
command.In your terminal run the below commands,
git init # Initializes a new Git repository locally (if not already initialized).
git add . /git add filename # Stages all the changes for commit.
git commit -m "Initial commit" # Commits the changes.
Connect to Remote Repository: ๐
Now, link your local repository to the remote repository on GitHub:
git remote add origin https://<GITHUB_ACCESS_TOKEN>@github.com/<GITHUB_USERNAME>/<REPOSITORY_NAME>.git
Push Local Changes to Remote Repository: ๐
git push -u origin master
This command pushes the changes to the "master" branch of the remote repository.