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 helps users find useful applications.
If you're interacting with source code, open source or otherwise, there's a strong likelihood you're going to interact with Git.
With so many people using Git every day, I wondered what the open source community's favorite Git commands are, and why.
What better way to find out than to ask?

## git diff

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

```bash
git diff --word-diff file1 file2
```

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

```bash
git diff --word-diff file1 file2
```

—Kartik Subbarao

## git status

I have two specific Git commands I can't live without.
The first is `git status`.
This one is great if I've recently adjusted my `.gitignore`, and I'm not sure 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, and then I can do one last PHPCS run-through.

—[Mirian Goldman](https://opensource.com/users/miriamgoldman)

## 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.
Really simple to use, but incredibly effective.

Also, if I can create a script that tells me whether the current source is good or bad, then `git bisect run` can figure everything out on it's own!

—Mohammed Saud (writers list)

## git stash

At work, I have to deal with customer projects in order to reproduce special kinds of behaviour.
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 to something great.
Either way, I can always ‘pop’ back from it and return to my work in progress.

—Diego Pino Navarro
dpino (email [email protected])

## 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 (writers list)

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 (qymanab)

## git merge

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

```bash
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 it's getting merged into.

—Joël Krähemann (writer's list)

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.

—mandclu

## 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 (he/him)
@seanedietrich
https://twitter.com/seanedietrich/status/1491276198370246658

## 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
@dgurin
https://twitter.com/dgurin/status/1491396447534993408


## Your git command

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