🌟Day 12 Insights: Mastering Git and GitHub Basics with Shubham Londhe

Β·

3 min read

🌟Day 12 Insights: Mastering Git and GitHub Basics with Shubham Londhe

Hello, DevOps enthusiasts! 🌟

Today, I joined an insightful live session with Shubham Londhe sir, also known as TrainWithShubham, where I learned a lot about Git and GitHub fundamentals. Let me share the highlights and my learnings with you.

What is Git? πŸ§‘β€πŸ’»

Git is a powerful version control system. Think of it as a tool that helps you keep track of changes you make to files over time. Imagine you’re writing a book and you want to save every version of it, so you can always go back to any previous version whenever you want. Git does exactly that but for code and any other type of file.

What is GitHub? 🌐

GitHub is like a social media platform for developers. It’s where you can store your Git projects online, collaborate with others, and showcase your work. It makes teamwork on coding projects super efficient and organized.

Key Takeaways from the Session:

  1. Version Control Basics πŸ“‚

    • Tracking Changes: Git allows you to track every change you make to your files.

    • Snapshots: Each set of changes is saved as a snapshot, which you can revert to anytime.

  2. Branching and Merging πŸŒΏπŸ”€

    • Branching: Create separate branches to work on new features without affecting the main project.

    • Merging: Combine branches back into the main project once the feature is ready.

  3. Collaboration on GitHub 🀝

    • Pull Requests: Propose changes to a project and discuss them with your team before integrating them.

    • Issues and Discussions: Keep track of bugs, enhancements, and overall project management.

Example: Creating and Managing a Simple Project

Here's a quick example to illustrate these concepts.

Step 1: Initialize a Git Repository

First, we need to create a new project and initialize it with Git:

mkdir MyProject
cd MyProject
git init

This command sets up a new Git repository in your project folder.

Step 2: Create and Track a File

Next, create a file and start tracking it with Git:

echo "Hello, World!" > hello.txt
git add hello.txt
git commit -m "Initial commit with hello.txt"

This sequence of commands creates a file called hello.txt, stages it (prepares it to be committed), and then commits it to the repository with a message.

Step 3: Create a New Branch

Now, let's say you want to add a new feature. Create a new branch to work on this feature without affecting the main codebase:

git checkout -b new-feature
echo "This is a new feature" > feature.txt
git add feature.txt
git commit -m "Added new feature"

You have now created a new branch called new-feature, added a file, and committed it.

Step 4: Merge the Branch

Once the feature is ready, you can merge it back into the main branch (often called master or main):

git checkout main
git merge new-feature

This command switches back to the main branch and merges the changes from new-feature into it.

Step 5: Push to GitHub

To collaborate with others, push your changes to GitHub:

git remote add origin https://github.com/yourusername/MyProject.git
git push -u origin main

This command links your local repository to a remote one on GitHub and pushes your changes.

Learn More from Shubham Londhe πŸ“Ί

If you want to dive deeper into Git and GitHub, check out Shubham Londhe's YouTube channel, TrainWithShubham. It's packed with valuable tutorials and insights that will enhance your understanding and proficiency in these tools.

πŸ‘‰ https://www.youtube.com/Shubham Londhe


Stay tuned for more updates on my DevOps journey! πŸ“…

Feel free to reach out to me if you have any questions or need any more help. Let’s connect, learn, and succeed together!

Happy Learning!😊

Β