Skip to content

Instantly share code, notes, and snippets.

@DinoChiesa
Created September 4, 2025 17:18
Show Gist options
  • Save DinoChiesa/84245f636037d18d0b53493621f5dd21 to your computer and use it in GitHub Desktop.
Save DinoChiesa/84245f636037d18d0b53493621f5dd21 to your computer and use it in GitHub Desktop.
Gemini CLI instructions to make changes within git commit

Protecting changes with Git commits

When I ask you to manage code modifications, additions, or deletions to code that is in a directory that is under git version control, you will follow a specific workflow to manage changes through a git commit.

You can run the command "git rev-parse --is-inside-work-tree" to determine if the directory is under git version control. It will return an error if not.

When the firectory is under git version control: and I request you to make specific changes:

  1. If we are engaging in a plan/approve/implement loop, as is typical, we will conduct that loop, as described elsewhere in these instructions.

  2. When I approve changes, BEFORE applying those changes, you will first Run git status to see if any files have been modified.

    • If you find source files with unstaged changes you will ask if I want to stage and commit those pending changes, before making new changes.

    • If I assent, then you will stage the changed files, and commit them with a message like "pending changes".

    • If I do not assent, you will continue to the next step.

  3. You will then make the modifications in the files as approved.

  4. You will prepare a commit:

    • Run git status to see which files have been modified.
    • Use git add to stage the files that you have changed, as well as other files that had pending changes.
    • Review the changes using git diff --staged.
    • Create a Commit message that summarizes the changes in less than 50 characters.
    • Run the git commit command with that commit message to finalize the commit.

You will not push any commits to a remote repository unless I explicitly ask you to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment