• Skip to main content
  • Skip to after header navigation
  • Skip to site footer

Free-Mail

  • Events
  • Images
    • Instagram Goodness
  • Music
  • News
  • Software

Happy anniversary, Git! Here are our favorite Git commands

Happy anniversary, Git! Here are our favorite Git commands: Happy anniversary, Git! Here are our favorite Git commands AmyJune Hineline Thu, 04/07/2022 – 03:00

Up
Register or Login to like.

Git’s 17th anniversary is on April 7th, 2022. Since its creation, Git has become a standard tool for software development. It helps programmers track changes they make to their code, and as a code hosting platform, it allows users to find useful applications. If you interact with source code, open source or otherwise, there’s a strong likelihood you interact with Git. With so many people using Git daily, I wondered what the open source community’s favorite Git commands are. What better way to find out than to ask?

More on Git
What is Git?
Git cheat sheet
Markdown cheat sheet
New Git articles

git diff

One of the hidden gems of Git is its ability to do word-level diffs.

 $   git diff --word-diff file1 file2

It’s not just for Git repos, either. It can also diff arbitrary files:

 $   git diff --word-diff file1 file2

—Kartik Subbarao

git status

I can’t live without the git status command. This one is great if I’ve recently adjusted my .gitignore, and I’m unsure if I got the syntax correct. It’s also nice if I want to quickly see which PHP, SCSS, or JavaScript files are being committed before I do one last PHPCS run-through.

—Miriam Goldman

git cherry-pick

I use git cherry-pick if I have been working on a branch and want to only keep one or two commits. I can pull out the changes from a single commit and apply them to the branch I’m working on now. It’s useful when there are merge conflicts, but there is an important change(s) you need for some reason.

—Ryan Price

git blame

I use git blame because invariably when I stare at code and ask, “who did this?!” the answer ends up being me. It’s usually something I did long ago, and I’ve forgotten why it had to be that way. If it wasn’t me, then it gives me a pointer to go and ask someone why they did it and why it had to be that way.

—John ‘Warthog9’ Hawley

git bisect

My favorite has to be git bisect. It helps identify the commit that introduced a bug by doing a binary search on commits. Simple to use but incredibly effective.

Also, if I create a script that tells me whether the current source is good or bad, then git bisect run figures everything out on its own!

—Mohammed Saud

git stash

At work, I have to deal with customer projects in order to reproduce specific kinds of behavior. The git stash command allows me to get back to the initial state very quickly after I’ve applied changes to the projects I want to revert.

—Stephan Avenwedde

Easily git stash! I get derailed a lot into urgent matters (bug fixes) while coding a longer piece. I love how verbose it is. It matches how my brain works. But it’s not only about being distracted into more urgent matters. Sometimes, stash serves a higher purpose: The need to chase a divergent solution to something already solved. Maybe it’s more elegant or chaotic. Maybe it’s just a clean slate, a hiatus that might lead to nothing or something great. Either way, I can always pop back from it and return to my work in progress.

—Diego Pino Navarro

I love using git stash and having the ability to stash changes that I’m not sure about and being able to recall them later. It is a great way to be able to noodle around with an idea.

—Michael Anello

git push

The first reason is I love git push is that it simply allows you to share your work—your code—with others! The second reason is that push --force is considered harmful and destructive, but I like to see it as a great power that comes with great responsibility. ?

—Noaa Barki

My practical answer: git add -p because it allows me to have that extra review step before I commit my code. Also, I can quickly add just the relevant changes and then do away with any pseudocode or debugging nonsense that’s leftover.

My real answer: git push because it reminds me of the song “Kick, Push” by Lupe Fiasco and also means, “I did the thing and all that remains is opening a PR.”

—Qymana Botts

[ Keep this command on hand and more with our updated Git cheat sheet. ]

git merge

My favorite Git command is git merge. Specifically, I love merging development branches into the master branch with the following:

 $   git merge --strategy recursive -X theirs 3.17.x

The theirs option within the recursive merge strategy incorporates changes from their side, as long as the changes don’t conflict with what they are getting merged into.

—Joël Krähemann

If you know you never want to override local values when doing a merge, the -Xours flag is a big-time saver, especially when used to sync code between mirrored repos. Should it find a conflict, it forces Git to preserve the local value and ignore any incoming changes.

—Martin Anderson-Clutz

git reset

As I find myself constantly having to abandon changes or needing to make sure my local branch is synced with the remote, I use git reset a lot. I also find it a helpful command as it allows me to reset my branch and go back in my repository history.

—Sean Dietrich

git reflog or rebase?

The command git reflog is my Lord and savior, but git rebase -i is my fave because I like to rewrite history.

—Dan Gurin

Your git command

There are plenty of Git commands to choose from, so what’s your favorite? Is there a dream command that Git’s lacking? Tell us in the comments!

Download our updated Git cheat sheet

For its 17th anniversary, I thought I’d round up the Opensource.com community’s favorite Git commands.

Terminal command prompt on orange background
Image by:

iradaturrahmat via Pixabay, CC0

Git
Opensource.com community

What to read next
What Git aliases are in your .bashrc?
10 Git tips we can’t live without

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.
Register or Login to post a comment.

: Opensource.com AmyJune Hineline

Supporting Open Source.

Have you tried: Travelling to South Africa?

Share this:

  • Share on Facebook (Opens in new window) Facebook
  • Share on X (Opens in new window) X
  • Share on Pinterest (Opens in new window) Pinterest
  • Email a link to a friend (Opens in new window) Email
  • More
  • Share on Tumblr (Opens in new window) Tumblr
  • Print (Opens in new window) Print
  • Share on LinkedIn (Opens in new window) LinkedIn
  • Share on Reddit (Opens in new window) Reddit
Published on 7 April 2022 by Alan Category: SoftwareTag: Anniversary, commands, Favorite, Happy, Here

How the world might look if animals had legal rights

How the world might look if animals had legal rights: Orapin Joyphuem/Shutterstock Let’s picture …

Read moreHow the world might look if animals had legal rights

Image from page 175 of “A great year Lord Glanely’s horses” (1921)

A nice Paternoster image: Image from page 175 of “A great year Lord Glanely’s …

Read moreImage from page 175 of “A great year Lord Glanely’s horses” (1921)

How costumes in period dramas shape our perception of royalty

How costumes in period dramas shape our perception of royalty: Our version of the present-day royals …

Read moreHow costumes in period dramas shape our perception of royalty

About Alan

Previous Post:Wieliczka
Next Post:Trending Now: Foray

Reach Trust

Reach Trust is a holding trust for a number of companies within the Stratlec Group.

Copyright © 2026 · Free-Mail · All Rights Reserved · Powered by Straton Electrical

Back to top