5 Git Commands You Shouldn’t Ignore
Tags: git, programmingtips, versioncontrol, coding
Published: 2023-09-12 13:07:25

You’re probably already a pro at using Git’s ‘A-list’ commands: git commit, git push, and git pull. But beyond these, there are powerful commands that often fly under the radar. Not only can they save you time, but they can also change the way you think about version control.

## 1\. Git Stash: Safe Your Coding

Imagine You’re deep into coding a new feature, and suddenly, a high-priority bug report interrupts you. You don’t have to rush to commit your half-done code.

Instead, you can just “stash” it away safely. This lets you fix the urgent bugs first and then easily get back to your feature work.

```javascript
git stash save "Work in progress for new feature"
```

## 2\. Git Bisect: Bug Detective

Finding a new bug is like looking for a needle in a haystack of commits. Don’t bother going through each one individually — `git bisect` is a more efficient way to find bugs.

Using a binary search algorithm, it quickly identifies the problematic commit causing the problem.

```javascript
git bisect start
git bisect bad
git bisect good [good_commit]
```

## 3\. Git Cherry-Pick: Selective Genius Import

Imagine you’ve spotted a great fix or feature in another branch. Instead of dragging along all the other commits through a merge, why not `‘cherry-pick’` just the genius you need?

```javascript
git cherry-pick [commit_hash]
```

{% twitter https://twitter.com/mainulspace/status/1701233753266225623?s=20 %}

## 4\. Git Reflog: Undo Button for Git

Have you ever wished you could roll back a botched git command? Enter `git reflog`. It keeps a record of every move you’ve made, making it easy to turn back the clock and recover lost commits.

```javascript
git reflog
```

## 5\. Git Rebase -i: Commit Curator

Before you release your excellent new feature, cleaning up your commit history is a good idea. Interactive Rebase (`git rebase -i`) lets you reorder, squash, or amend commits, creating a polished history that’s easy to follow.

```javascript
git rebase -i [base_commit]
```

## Conclusion

Git offers so much more than the popular commands we use daily. These less-used commands can supercharge your workflow, make it easy to track bugs, and even save your day in case of emergency commits.

So, exploring these Git’s lesser-known features and learning will make your coding workflow smoother. Not only will you become a more capable developer, but you will also take your version control to new heights.

Which of these Git commands are new to you? Have you encountered a situation where one could have been a lifesaver? Share your experiences, tips, and tricks in the comments below.

Feel free to connect with me on [**Twitter**](https://twitter.com/mainulspace) or [**LinkedIn**](https://www.linkedin.com/in/mainulspace/).

## Read Next...
{% embed https://dev.to/mainulspace/10-lesser-known-javascript-array-methods-you-mightve-missed-32b3 %}
{% embed https://dev.to/mainulspace/10-underutilized-css-properties-every-developer-should-know-2ia0 %}
{% embed https://dev.to/mainulspace/are-you-using-javascript-right-know-when-to-go-asynchronous-4731 %}