Table of contents
- β±What is Git and why is it important?
- β±What is the difference between the Main Branch and the Master Branch?
- β±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?
- β±Git command to set your user name and email address, which will be associated with your commits
β±What is Git and why is it important?
Git is a magical time-traveling tool for your code. π°οΈ
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. πΎ
Branch Magician: Let you try out new ideas without affecting the main project. π³
Collaboration: Makes it easy for coders to share and combine their work. π€
Why it's important:
No Chaos: Helps avoid coding chaos and confusion. π§
Team Harmony: Makes teamwork smooth and happy. π€
Safe Coding: Protects your code like a superhero shield. π¦ΈββοΈ
Time Travel: Let you go back in time if you make a mistake. β°
Global Friend: Coders worldwide use it for a peaceful coding universe. π
Git is like a coding superhero that keeps everything organized, safe, and happy for coders! π¦ΈββοΈπ»
β±What is the difference between the Main Branch and the Master Branch?
Master Branch:
Old Terminology: In the past, "master" was the default and main branch in Git where stable code lives. π‘
Some projects still use "master" as the main branch.
Main Branch:
Modern Term: Many projects now use "main" instead of "master" for the default branch.
Reflects a move towards more neutral and inclusive language.
Why the Change?
"Main" is the new cool, while "Master" is a classic term. Main and Master are just different names for the primary branch. However, concerns about potential negative connotations led to a shift towards "main" for inclusivity. Both terms serve the same purpose, storing the primary version of a project's source code. The choice between them depends on cultural shifts and individual preferences within the coding community.
β±Explain the difference between Git and GitHub.
Difference:
Git: It's the tool you use on your computer for version control.
GitHub: It's the online platform where your code and the superhero Git can mingle with other developers.
β±How do you create a new repository on GitHub?
Go to GitHub:
- Open your web browser and go to GitHub.
Sign In:
- If you're not already signed in, click "Sign In" and enter your credentials. πͺπ
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: π‘ Your personal coding space on your computer, where you create and experiment.
Remote Repository: π The shared space on the internet 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.
β±Git command to set your user name and email address, which will be associated with your commits
git config --global user.name "your_name"
git config --global user.email "example@gamil.com"
git config --list -> Displays all the Git configuration settings currently in use.