exit code -1 - git push

Exit Code -1 After a Git Push? It Might Be Your Secrets or Vulnerable Code

What does “exit code -1” after a git push mean?

Getting exit code -1 after a git push? It’s often your CI/CD pipeline protecting your app from secrets or vulnerable code. It’s a clear signal that your CI/CD pipeline detected a security issue, like hardcoded secrets or vulnerable dependencies,  and deliberately blocked the deployment to protect your application.

Why Does Exit Code -1 Happen After Git Push?

When your code hits the remote repo, the CI/CD pipeline runs automated checks. If any of these detect a security risk,  such as secrets in code, vulnerable dependencies, or insecure logic,  the pipeline halts and returns exit code -1. These checks act as security gates: they stop the deployment if certain conditions aren’t met, regardless of whether the code compiles.

What It Looks Like When the Pipeline Fails (and Why)?

Here’s a unified snapshot of what might trigger that exit code -1 and why it matters:

Scenario Example Output Cause Detected
Secrets in code [Security Scan] Found hardcoded API_KEY in config/settings.js Prevents leaking credentials
Vulnerable dependency [Dependency Check] Critical CVE-2023-32681 in ExampleLib 2.0.1 Blocks known exploit vectors
Insecure code pattern [CodeQL] SQL injection risk in controllers/user.js Stops unsafe coding practices

Even though these cases differ, the result is the same: a fail-fast approach that protects your application.

How Pipelines Detect Problems

Security scans can run both before and after the push:

  • Pre-push: Catch issues early with Git hooks (pre-commit, pre-push) that scan for secrets and unsafe patterns.
  • CI/CD pipeline: Run the full suite of security checks post-push, using tools like detect-secrets, dependency-check, or CodeQL.

Example CI/CD security stage:

security-check:
  stage: test
  script:
    - detect-secrets scan               # Scans for hardcoded secrets in the codebase
    - dependency-check --failOnCVSS 9   # Fails if dependencies have critical vulnerabilities (CVSS score ≥ 9)
    - codeql analyze                    # (Optional) Analyzes code for insecure patterns (e.g., SQL injection)
  allow_failure: false                  # Ensures that the pipeline fails if any check fails

If any tool flags an issue, the pipeline fails with exit code -1 (or 1), halting deployment before anything risky goes live.

Preventing Exit Code -1 Before You Push

Push failures are frustrating. The best defense is to catch issues before the code reaches the remote repo.

 Mini-checklist to prevent exit code -1 locally:

  •  Run a local secrets scan (pre-commit or pre-push Git hooks)
  •  Use IDE security plugins (e.g., SonarLint, ESLint rules,…)
  •  Audit dependencies with tools like npm audit or pip-audit

Example: Local Git pre-push hook

# .git/hooks/pre-push

detect-secrets scan   # Run a local secrets scan before allowing the push
if [ $? -ne 0 ]; then
  echo "Secrets detected. Push aborted."   # Prevent the push if any secret is found
  exit 1
fi

Security validation in your IDE

  • Use security-focused plugins for your editor (like ESLint security rules, Snyk, or SonarLint) to catch risky patterns while coding.

Check dependencies before pushing

  • npm audit         # For Node.js projects
  • pip-audit         # For Python projects

Catching these issues early avoids most exit code -1 and exit code 1 pipeline failures.

Handling False Positives Safely

Security tools sometimes flag safe code,  but disabling checks entirely is risky.

⚠️ Don’t overuse whitelisting

Too many exemptions can make your security gates ineffective. Whitelist only when necessary, and always document why.

 Safe way to reduce false positives

Use configuration rules to exclude known safe files (e.g., sample configs, test fixtures), while keeping checks active for critical paths.

Example: detect-secrets config to ignore test files safely

# .secrets.baseline
exclude:
  files:
    - "tests/.*"              # Skip tests directory
    - "docs/example_configs"  # Ignore sample config files

This approach avoids unnecessary pipeline failures without compromising security. Keep your exceptions narrow and auditable.

Building Security Habits Over Time – Exit Code -1

Adopting security checks becomes second nature:

  1. Run scans while coding
  2. Fix flagged issues early
  3. Keep dependencies updated
  4. Reduce future failures by shifting left

Tool Spotlight: Xygeni for Automated Enforcement

Manual scans can catch issues early, but to ensure consistent enforcement across teams, security should also be automated inside CI/CD pipelines.

Xygeni integrates directly into your pipeline and scans each commit or merge for:

It can block deployments when high-risk issues are detected, helping maintain security gates at scale without relying solely on manual reviews.

Example: Xygeni in a CI/CD pipeline:

security-scan:
  stage: security
  script:
    - xygeni scan --fail-on-severity high   # Block pipeline if high-severity issues are detected
  allow_failure: false                      # Enforce the result — no bypass on failure

Placing this stage before deployment ensures that any serious security issue causes an immediate exit code -1, stopping unsafe code from reaching production.

Key Takeaways

An exit code -1 after a git push doesn’t mean something went wrong; it means your CI/CD pipeline did its job. It blocked a potentially risky deployment before it reached production.

Rather than treating this as a frustration, see it as a security checkpoint built to protect your code, infrastructure, and users.

But don’t wait for the pipeline to catch problems. Integrate validation steps throughout the entire development lifecycle:

  • While coding: Use IDE plugins and linters to detect issues in real time
  • Before committing: Use Git hooks to run local scans for secrets or risky dependencies
  • In CI/CD: Enforce strict gates that stop insecure changes from merging or deploying

When security checks become part of your daily flow, exit code -1 becomes rare because prevention is built in from the start.

Final Thoughts

The error: pg_config executable not found message is common, but how you handle it matters. Secure installations, verified sources, reproducible builds, and pipeline security controls turn a frustrating build failure into an opportunity to strengthen your DevSecOps posture.

sca-tools-software-composition-analysis-tools
Prioritize, remediate, and secure your software risks
7-day free trial
No credit card required

Secure your Software Development and Delivery

with Xygeni Product Suite