☑️Day 13: Advanced Git & GitHub with Shubham Londhe!

☑️Day 13: Advanced Git & GitHub with Shubham Londhe!

Hello, DevOps enthusiasts! 🌟

Today, I joined another insightful live session with Shubham Londhe Sir also Known as TrainWithShubham, where I learned a lot about advanced Git & GitHub for DevOps Engineers. Let me share the highlights and my learnings with you.

🔹Table Of content :

✅Git Branching

✅Git Revert and Reset

✅Git Rebase and Merge.

✅Git Branching :

  • Branching in Git lets developers work on different parts of a project without messing up the main version.

  • It's like creating separate workspaces where you can try out new ideas or fix problems without affecting the main code. And when you're done, Git helps you merge these changes back in smoothly, so everything works together nicely.

Commands:

  1. To Check the current branch

       git branch
    
  2. To Create a branch

       git branch <name_of_branch>
    
  3. To Checkout and Create a branch at the same time

       git checkout -b <name_of_branch>
    
  4. To list all branches

       git branch -a
    
  5. To Delete a branch

       git checkout -d <name_of_branch>
    

✅Git Revert and Reset :

  • Git gives developers two important tools: git revert and git reset, to handle changes effectively.

  • Git revert helps you undo specific commits by creating new ones, making it a safe way to roll back changes without messing up the history of your project.

  • On the other hand, git reset lets you go back to a previous state of your project, giving you more control over how you manage changes in your code.

Commands:

  1. To Revert a change

       git revert <Hash_code_of_the_commit>
    
  2. To Revert the previous commit

       git revert HEAD
    

Commands:

git reset --soft HEAD~n 
git reser --hard HEAD~n

There are two types of resetting in Git:

--soft: This option resets the commit but keeps it accessible in the Git history. It's like undoing the commit without completely erasing its existence.

--hard: This option resets the commit and completely removes it. It's as if the commit never existed in the first place, making it inaccessible in the Git history.

Where n is the number of commits respectively from the head we want to reset.

✅Git Rebase and Merge.

✨Git rebase and Merge:

MergeRebase
Git Merge lets you merge different Git branches.Git Rebase allows you to integrate the changes from one branch into another.
Git Merge logs show you the complete history of commit merging.Git Rebase logs are linear. As the commits are rebased, the history is altered to reflect this.
All the commits on a feature branch are combined into a single commit on the master branch.All commits are rebased, and the same number of commits are added to the master branch.
Merge is best used when the target branch is supposed to be shared.Rebase is best used when the target branch is private.
Merge preserves history.Rebase rewrites history.

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/@TrainWithShubham


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!😊