Skip to content

πŸ™Œ OpenHands: AI-Driven Development

Do not override user's git config in CLI mode or local machine (#9905)

Engel Nyst8fb372839113
diff --git a/openhands/agenthub/codeact_agent/prompts/system_prompt.j2 b/openhands/agenthub/codeact_agent/prompts/system_prompt.j2
index fe82515d46..de1cfc6569 100644
--- a/openhands/agenthub/codeact_agent/prompts/system_prompt.j2
+++ b/openhands/agenthub/codeact_agent/prompts/system_prompt.j2
@@ -31,7 +31,7 @@ Your primary role is to assist users by executing commands, modifying code, and
</CODE_QUALITY>
<VERSION_CONTROL>
-* When configuring git credentials, use "openhands" as the user.name and "[email protected]" as the user.email by default, unless explicitly instructed otherwise.
+* When committing changes, you MUST use the `--author` flag to set the author to `"openhands <[email protected]>"`. For example: `git commit --author="openhands <[email protected]>" -m "Fix bug"`. This ensures all commits are attributed to the OpenHands agent, regardless of the local git config.
* Exercise caution with git operations. Do NOT make potentially dangerous changes (e.g., pushing to main, deleting repositories) unless explicitly asked to do so.
* When committing changes, use `git status` to see all modified files, and stage all files necessary for the commit. Use `git commit -a` whenever possible.
* Do NOT commit files that typically shouldn't go into version control (e.g., node_modules/, .env files, build directories, cache files, large binaries) unless explicitly instructed by the user.
diff --git a/openhands/agenthub/codeact_agent/prompts/system_prompt_interactive.j2 b/openhands/agenthub/codeact_agent/prompts/system_prompt_interactive.j2
index 5af470c5b6..14f9a6f248 100644
--- a/openhands/agenthub/codeact_agent/prompts/system_prompt_interactive.j2
+++ b/openhands/agenthub/codeact_agent/prompts/system_prompt_interactive.j2
@@ -25,7 +25,7 @@ Your primary role is to assist users by executing commands, modifying code, and
</CODE_QUALITY>
<VERSION_CONTROL>
-* When configuring git credentials, use "openhands" as the user.name and "[email protected]" as the user.email by default, unless explicitly instructed otherwise.
+* When committing changes, you MUST use the `--author` flag to set the author to `"openhands <[email protected]>"`. For example: `git commit --author="openhands <[email protected]>" -m "Fix bug"`. This ensures all commits are attributed to the OpenHands agent, regardless of the local git config.
* Exercise caution with git operations. Do NOT make potentially dangerous changes (e.g., pushing to main, deleting repositories) unless explicitly asked to do so.
* When committing changes, use `git status` to see all modified files, and stage all files necessary for the commit. Use `git commit -a` whenever possible.
* Do NOT commit files that typically shouldn't go into version control (e.g., node_modules/, .env files, build directories, cache files, large binaries) unless explicitly instructed by the user.
diff --git a/openhands/agenthub/codeact_agent/prompts/system_prompt_long_horizon.j2 b/openhands/agenthub/codeact_agent/prompts/system_prompt_long_horizon.j2
index 4fdad14cc7..39c06c4867 100644
--- a/openhands/agenthub/codeact_agent/prompts/system_prompt_long_horizon.j2
+++ b/openhands/agenthub/codeact_agent/prompts/system_prompt_long_horizon.j2
@@ -25,7 +25,7 @@ Your primary role is to assist users by executing commands, modifying code, and
</CODE_QUALITY>
<VERSION_CONTROL>
-* When configuring git credentials, use "openhands" as the user.name and "[email protected]" as the user.email by default, unless explicitly instructed otherwise.
+* When committing changes, you MUST use the `--author` flag to set the author to `"openhands <[email protected]>"`. For example: `git commit --author="openhands <[email protected]>" -m "Fix bug"`. This ensures all commits are attributed to the OpenHands agent, regardless of the local git config.
* Exercise caution with git operations. Do NOT make potentially dangerous changes (e.g., pushing to main, deleting repositories) unless explicitly asked to do so.
* When committing changes, use `git status` to see all modified files, and stage all files necessary for the commit. Use `git commit -a` whenever possible.
* Do NOT commit files that typically shouldn't go into version control (e.g., node_modules/, .env files, build directories, cache files, large binaries) unless explicitly instructed by the user.