# How I used this one Git command to unblock my team

## **Backstory**

In one of our Slack channels for work, I saw a message. The message goes something like this:

> @here &lt;project-name&gt; is not running properly on local. Just taken a fresh pull from master and installed node\_modules. \[The developer attached a screenshot to the message\].
> 
> ~ a developer

Many developers saw the message and many developers upvoted the issue with ⬆️. There was no update. This issue was preventing my team and others from completing their assigned task. Heck, even designers were blocked because they could not do their UI/UX review. Why? Well because the issue broke the application in the **Canary** environment as well. Once I was done with my daily tasks and meetings, I decided to look into the issue. I was aware that to identify the problem, I'd need to check the diffs and navigate to the commit where the code was functioning correctly.

## Git Command

In the quest to decipher and resolve issues within a project, a systematic approach is key. But first, let me tell you about one of the most underrated Git commands that I frequently use to investigate issues, similar to the one I encountered at work. This git command is `git checkout`.

```bash
git checkout <hash>
```

This command is an invaluable asset when troubleshooting issues. I have used this git command many times throughout my career. Below are some common scenarios for which I use this command:

* **Creating a hotfix:** Quickly address critical issues in the production environment by using `git checkout` to create a hotfix branch. This allows developers to isolate and resolve urgent problems without disrupting the main development workflow.
    
* **Inspecting a commit:** Utilize `git checkout` to examine the state of your project at a specific commit. This enables a detailed review of changes, helping to pinpoint when a particular modification was introduced.
    
* **Creating a new branch:** Seamlessly initiate work on a new task or feature by using `git checkout -b <branch-name>` to create a fresh branch. This fundamental operation ensures that development efforts remain organized, isolated, and conducive to collaborative coding practices.
    
* **Switching between branches:** Effortlessly navigate through different branches using `git checkout`, enabling developers to switch contexts seamlessly. Whether moving from feature development to the main branch or exploring experimental features, this command facilitates a smooth transition in the version-controlled codebase.
    

## Investigation

Now that you know about `git checkout` and the the back story of the issue, let me tell you about the steps I took to resolve the issue. In the screenshot shared by the developer, the error was along the lines of *Module not found: Error Can't resolve 'fs' in &lt;path&gt;/winston*.

After reading the error message, my first thought was, "Why are we using winston on the client side?". The first thing I did was, `git checkout master` on my local, pulled the latest master, installed the latest packages with the command `npm install` and `npm run dev`. I was able to see the exact error.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1703201565474/0c89fbe9-d63b-4952-bc34-a49be87d5c23.jpeg align="center")

Then on GitHub, I started looking at the `diff` of each commit in the master branch to see if I could find some changes related to winston. After checking some hashes, I saw that `#9cc759` had some changes to do with winston. A developer had added winston logger on the client side of the application. Hence the error message, *Module not found: Error Can't resolve 'fs' in &lt;path&gt;/winston*. Then I decided to navigate to the previous git commit by using the command `git checkout f600e5`, followed by `npm install` and `npm run dev`.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1703201560348/6367e22b-1ff9-46e4-b68d-55401f1d0613.jpeg align="center")

BAM! The application was working as expected. Then I `git checkout 9cc759`, `npm install` and executed `npm run dev`. As expected, I saw the same exact error in the terminal.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1703201548013/5b3fb712-5bc8-4334-a1da-55cc58c09297.jpeg align="center")

I had found the culprit. I quickly `git checkout master`, removed the `winston` related code, `npm install`, and `npm run dev` and I did not see the error *Module not found: Error Can't resolve 'fs' in &lt;path&gt;/winston*. The application was working as expected. I pushed the code and raised the PR. I quickly notified the team in our Slack channel that I had determined the issue and shared the PR link. The PR was merged, and the team was fully unblocked.
