# Running git diff --exit-code

**URL:** <https://forum.buildkite.community/t/running-git-diff-exit-code/4228>\
**Category:** General\
**Created:** [February 13, 2025, 11:17pm UTC](https://forum.buildkite.community/t/running-git-diff-exit-code/4228 "2025-02-13T23:17:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fansari1](https://avatars.discourse-cdn.com/v4/letter/f/65b543/32.png) [@fansari1](https://forum.buildkite.community/u/fansari1)\
**Post date:** [February 13, 2025, 11:17pm UTC](https://forum.buildkite.community/t/running-git-diff-exit-code/4228/1 "2025-02-13T23:17:08Z")

</div>

Hi,  
I’m building a step in my pipeline that checks if the developer has ran the formatting step or not.

In a nutshell, my logic involves running `golines ./ --max-len=120 --write-output` and checking for any files that were written using `git diff --exit-code`

However, I’m running into git error 129 which I’m unable to decipher.  
Can you please help me out with this?

Step:

```auto
  - label: "NP | Check go formatting"
    key: "np-check-formatting"
    commands: |
      set -euo pipefail
      cd networkplanner
      
      echo --- Checking for formatting
      make format
      
      cd ..
      if ! git diff --exit-code; then
          echo "Go files were not formatted correctly. Please commit the changes after running make format."
          git diff # Show the differences
          exit 1
      else
          echo "All Go files are formatted correctly."
      fi
    plugins:
      - docker#v5.9.0:
          image: "golang:1.22.1"
          volumes:
            # Necessary for docker-in-docker testcontainers
            - "/var/run/docker.sock:/var/run/docker.sock"
          network: "host"
          shell: ["/bin/bash", "-c"]
          environment:
            - GO_BIN_PATH=/go/bin

```

Link to pipeline → [https://buildkite.com/equinix/ngo-engineering/builds/2398#01950142-6c7b-450e-b6d8-df8b5bbe3448](https://buildkite.com/equinix/ngo-engineering/builds/2398#01950142-6c7b-450e-b6d8-df8b5bbe3448)

---

<div class="post-metadata">

**Author:** ![paula](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.buildkite.community/paula/32/954_2.png) [@paula](https://forum.buildkite.community/u/paula)\
**Post date:** [February 15, 2025, 4:52pm UTC](https://forum.buildkite.community/t/running-git-diff-exit-code/4228/2 "2025-02-15T16:52:00Z")

</div>

Hey! So to close the loop on this one. We had a conversation with the user and after some debugging and a couple of changes on their side, they are not getting git errors 129 anymore
