Git Helper
Ask Nova to suggest appropriate Git commands for version control tasks.
System Prompt Template
You are an expert {user description} who can {description of task}.
Follow these instructions:
{enumerated instructions}
User Prompt Template
### Task ###
{description of task}
Example
Amazon Nova Pro System Prompt
You are an expert Git user who can translate natural language descriptions into precise Git commands.
Follow these instructions:
1. Read and understand the version control task in ### Task ###
2. Analyze the requirements and context in ### Analysis ### and think step by step:
- Required Git operations
- Any potential risks or considerations
- Alternative approaches if applicable
3. Provide the Git commands in ### Commands ### using ```bash``` code blocks
4. Add explanations for each command in ### Explanation ###
Amazon Nova Pro User Prompt
### Task ###
I accidentally committed some sensitive credentials to my main branch in my last commit, but haven't pushed yet. I need to:
1. Remove the sensitive data from the commit
2. Keep all other changes from that commit
3. Make sure the credentials are ignored in future commits
The sensitive file is at 'config/credentials.json'.
Amazon Nova Pro Sample Response
Response
Analysis
To address this task, we need to perform the following steps:
- Remove the sensitive data from the commit:
-
We need to remove the
config/credentials.json
file from the last commit while keeping other changes intact. This can be done usinggit rm --cached
. -
Amend the last commit:
-
After removing the sensitive file, we need to amend the last commit to reflect this change. This can be done using
git commit --amend
. -
Ensure the credentials are ignored in future commits:
-
We need to add
config/credentials.json
to.gitignore
to prevent it from being tracked in future commits. -
Potential risks and considerations:
- Amending a commit that hasn’t been pushed is safe, but if the commit had been pushed, amending it would require force-pushing, which can be risky if others are working on the same branch.
-
Ensure that the
.gitignore
file is committed so that the ignore rule is shared with other collaborators. -
Alternative approaches:
- Another approach could be to use
git reset
to undo the commit, make the changes, and then re-commit. However,git commit --amend
is more straightforward for this specific scenario.
Commands
# Step 1: Remove the sensitive file from the last commit
git rm --cached config/credentials.json
# Step 2: Amend the last commit
git commit --amend --no-edit
# Step 3: Add the sensitive file to .gitignore
echo "config/credentials.json" >> .gitignore
# Step 4: Commit the .gitignore changes
git add .gitignore
git commit -m "Add config/credentials.json to .gitignore"
Explanation
git rm --cached config/credentials.json
: This command removes theconfig/credentials.json
file from the staging area but keeps it in the working directory. This ensures that the file is no longer tracked by Git but remains on your local filesystem.git commit --amend --no-edit
: This amends the last commit to remove theconfig/credentials.json
file. The--no-edit
flag keeps the original commit message unchanged.echo "config/credentials.json" >> .gitignore
: This appends theconfig/credentials.json
file to the.gitignore
file, ensuring it is ignored in future commits.git add .gitignore
: This stages the updated.gitignore
file.git commit -m "Add config/credentials.json to .gitignore"
: This commits the changes to the.gitignore
file with a descriptive message.
API Request
import boto3
import json
bedrock_runtime = boto3.client(
service_name="bedrock-runtime",
region_name="us-west-2"
)
response = bedrock_runtime.converse(
modelId='us.amazon.nova-pro-v1:0',
system = [
{
"text": """You are an expert Git user who can translate natural language descriptions into precise Git commands.
Follow these instructions:
1. Read and understand the version control task in ### Task ###
2. Analyze the requirements and the scenario, think step by step, and put your thoughts in ### Analysis ### in markdown formatting. Consider the following:
- Required Git operations
- Any potential risks or considerations
- Alternative approaches if applicable
3. Provide the Git commands in ### Commands ### using ```bash``` code blocks
4. Add explanations for each command in ### Explanation ### in markdown formatting.
"""
}
],
messages = [
{
"role": "user",
"content": [
{
"text": """### Task ###
I accidentally committed some sensitive credentials to my main branch in my last commit, but haven't pushed yet. I need to:
1. Remove the sensitive data from the commit
2. Keep all other changes from that commit
3. Make sure the credentials are ignored in future commits
The sensitive file is at 'config/credentials.json'."""
}
]
}
],
inferenceConfig={
"temperature": 0.1,
"topP": .99,
"maxTokens": 2000
}
)
print(json.dumps(response, indent=2))
aws bedrock-runtime converse \
--model-id "us.amazon.nova-pro-v1:0" \
--system '[
{
"text": "You are an expert Git user who can translate natural language descriptions into precise Git commands.\nFollow these instructions:\n1. Read and understand the version control task in ## Task ##\n2. Analyze the requirements and context in ## Analysis ##:\n - Required Git operations\n - Any potential risks or considerations\n - Alternative approaches if applicable\n3. Provide the Git commands in ## Commands ## using ```bash``` code blocks\n4. Add explanations for each command in ## Explanation ##"
}
]' \
--messages '[
{
"role": "user",
"content": [
{
"text": "## Task ##\nI accidentally committed some sensitive credentials to my main branch in my last commit, but haven'\''t pushed yet. I need to:\n1. Remove the sensitive data from the commit\n2. Keep all other changes from that commit\n3. Make sure the credentials are ignored in future commits\nThe sensitive file is at '\''config/credentials.json'\''."
}
]
}
]' \
--inference-config '{
"temperature": 0.1,
"topP": 0.99,
"maxTokens": 512
}' \
--region us-west-2
{
"modelId": "us.amazon.nova-pro-v1:0",
"system": [
{
"text": "You are an expert Git user who can translate natural language descriptions into precise Git commands.\nFollow these instructions:\n1. Read and understand the version control task in ## Task ##\n2. Analyze the requirements and context in ## Analysis ##:\n - Required Git operations\n - Any potential risks or considerations\n - Alternative approaches if applicable\n3. Provide the Git commands in ## Commands ## using ```bash``` code blocks\n4. Add explanations for each command in ## Explanation ##"
}
],
"messages": [
{
"role": "user",
"content": [
{
"text": "## Task ##\nI accidentally committed some sensitive credentials to my main branch in my last commit, but haven't pushed yet. I need to:\n1. Remove the sensitive data from the commit\n2. Keep all other changes from that commit\n3. Make sure the credentials are ignored in future commits\nThe sensitive file is at 'config/credentials.json'."
}
]
}
],
"inferenceConfig": {
"temperature": 0.1,
"topP": 0.99,
"maxTokens": 512
}
}