Git is an indispensable part of the code-sharing development workflow. Be you a beginner or an expert, this powerful version control system is the first thing you are expected to learn when working with open source code. You don't need to know everything under the sun when it comes to Git, but knowing specific hacks makes sharing your code a lot easier on platforms like GitLab, so you can collaborate with developers far and near. If there's something you're not sure about, git --help
can come to your rescue.
I'm amazed every day by the amount of control that knowing Git provides. There is not a single instance when you can't revert to an earlier version, however impossible or sticky the situation you may be in.
Opensource.com had a great set of articles regarding Git in 2021; I'm summarizing just the top 10. All the articles contain hacks, lesser-known facts, and tips and tricks that can come in handy while working with Git.
A practical guide to using the git stash command
Ramakrishna Pattnaik explains the functions of the git stash command. This article highlights how git stash
can help you list, check, save, and retrieve changes to ensure a hassle-free experience when switching branches. It can also help you track changes locally without committing and while maintaining a clean working directory.
5 commands to level up your Git game
Seth Kenlon details five lesser-known Git commands that can make your life easier. Developers can save time with commands like git whatchanged, git stash, git worktree,
and git cherry-pick
What is Git cherry-picking?
This tutorial by Rajeev Bera walks you through the what, why, and how of the git cherry-pick command and lists all possible use cases when git cherry-pick
will help you escape a sticky situation.
3 reasons I use the git cherry-pick command
I share how leveraging git cherry-pick can help you avoid redundancy, handle multiple commits in one go, and restore lost changes.
Experiment on your code freely with git worktree
The git stash
command takes care of saving changes to a working directory. Seth Kenlon introduces us to git worktree
and the several git worktree use cases that can help you get a repository back to a known state.
4 tips for context switching in Git
This article by Olaf Alders discusses the pros and cons of four different ways of switching branches while working with Git. These options will help you simplify your workflow and maintain a clean working directory without losing your changes.
Find what changed in a Git commit
Seth Kenlon explains how to leverage simple commands like git log and git whatchanged to extract specific information regarding what changed in a Git commit. It's a helpful shortcut, and the name makes it easy to remember.
7 Git tips for managing your home directory
Seth Kenlon shares the dos and don'ts of managing and organizing $HOME with Git and explains how it made his life more convenient across devices. Even better, it's freed him to experiment with new ideas, knowing he can roll them back easily.
GitOps vs. DevOps: What's the difference?
Bryant Son introduces you to GitOps, which he describes as an evolved version of DevOps that uses Git as the single source of truth. The article also lists helpful resources available on Opensource.com for learning DevOps and landing a job in open source.
Get started with Argo CD
Ayush Sharma details the advantages of Argo CD, a pull-based GitOps development tool. Argo CD gives you the best of both worlds by managing Kubernetes manifests in Git and syncing them in a cluster.
Can you think of other Git hacks that make your life easier? Please let us know in the comments or send us an article idea.
Comments are closed.