Introduction
You might have heard the terms "Git" and "GitHub" floating around, and you might be wondering what they're all about. Fear not, for we're here to break down these concepts in the simplest way possible, without any technical jargon! π
What's Git? β
Git (Global Information Tracker) is a version control system that allows your files to have version history. Git is primarily used for code management which acts like a version control system and allows you to collaborate. Imagine you're writing a story, and you want to keep track of all the changes you make. Git is like a magical story tracker! It's a tool that helps people work together on projects, just like your story. Whenever you make a change, Git takes a snapshot of your work and stores it, so you can go back to any version of your story whenever you want. No more lost ideas or overwritten paragraphs! ππΈ
What's GitHub? π
GitHub is a platform where we can create a remote repository and sync that with the local repository. Think of Git as the behind-the-scenes wizard, and GitHub as the stage where the magic happens. When you use Git to track changes in your story, you can also put your story on GitHub. This way, you can share your story with friends, let them contribute, and keep everything organized. It's like inviting friends to help write your story, but online! πΌπ
Basic Terms: π
Repository (Repo): This is like a folder where you keep your story and all its versions.
Commit: Whenever you make changes to your story, you create a "commit." It's like saving a checkpoint in a video game.
Branch: Imagine trying out a new idea without messing up your main story. A branch is a separate copy where you can experiment and make changes.
Pull Request: When you want to add changes from your branch to the main story, you send a "pull request." It's like asking your friends to review and include your new ideas.
Why Is It Cool
Version Control: No more "Oops, I deleted something important!" With Git, you can go back to any version of your story. π°οΈ
Collaboration: You and your friends can work on the same story without stepping on each other's toes. π€
Learning Together: You can see how others write and learn from them, just like sharing books. π
Resume Boost: Many people use GitHub to showcase their projects, even non-tech ones. It's like showing off your creations in an online gallery! πΌοΈ
Git Commands
git init: Imagine setting up a new journal. This command initializes a new "journal" for your project where you can start writing your story. This command makes the regular repository into a Git repository. the repository which you want to make a Git repository then you have to run this command in that repository.
git status: To list git files.
git add <file>: Like collecting your thoughts, this command adds specific files or changes to a list, preparing them to be recorded. means it adds the file to staging mode.
git rm --cached <file>: To transfer file to unstage mode.
git commit -m "message": Think of this as saving your work in your journal. It records the changes you've added and attaches a short message describing what you've done.
git restore <file>: To restore deleted file.
git log: Imagine flipping through your journal to see all your past entries. This command shows you a history of all the commits you've made.
git log --oneline: Same as git log just gives output in oneline means only shows the first line of git log command output.
git config --global user.name <name>: To change username.
git config --global user.email <email>: To change email.
git checkout -b <branchname>: To create new branch.
git checkout <branchname>: Switching to another branch is like exploring a different story. This command lets you move to a different branch to see what's happening there.
git branch: To list all branches.
git merge <branch>: Combining branches is like merging two storylines. This command takes changes from one branch and adds them to another.
GitHub Commands
git clone <repository URL>: Imagine borrowing a friend's journal to see their work. This command creates a copy of a repository from GitHub onto the local system.
git remote -v: This command shows the origin of the GitHub file in the local system.
git pull: Like updating your journal with the latest entries from your friend's journal. This command fetches and integrates changes from a remote repository (like GitHub) into your local one.
git push: Sharing your journal updates with your friends. This command sends your local changes to the remote repository (GitHub) so others can see them.
git remote set-url --add <name> <newurl>: To add new URL.
git remote set-url --delete <name> <url>: To delete URL.
In the upcoming blog, we will discuss some advanced parts of Git and GitHub.
If you have any doubt please drop a comment.
Keep Practicing!
Happy Learning!
Thank You!