At the terminal or command line, run the create-commit command, specifying:
The repository where you want to commit the changes.
The branch where you want to commit the changes.
The full commit ID of the most recent commit made to that branch, also known as the tip or head commit or the parent commit ID.
Whether to keep any empty folders if the changes you made delete the content of those folders. By default, this value is false.
The information about the files you want added, changed, or deleted.
The user name and email you want associated with these changes.
A commit message that explains why you made these changes.
The user name, email address, and commit message are optional, but help other users know who made the changes and why. If you do not supply a user name, CodeCommit defaults to using your IAM user name or a derivation of your console login as the author name.
For example, to create a commit for a repository that adds a README.md
file to a repository named MyDemoRepo
in the main
branch. The content of the file is in Base64 and reads "Welcome to our team repository!":
aws codecommit create-commit --repository-name MyDemoRepo
--branch-name main --parent-commit-id 4c925148EXAMPLE
--put-files "filePath=README.md,fileContent=V2VsY29tZSB0byBvdXIgdGVhbSByZXBvc2l0b3J5IQo="
Tip
To get the parent commit ID, run the get-branch command.
If successful, this command returns output similar to the following:
{
"commitId": "4df8b524-EXAMPLE",
"treeId": "55b57003-EXAMPLE",
"filesAdded": [
{
"blobId": "5e1c309dEXAMPLE",
"absolutePath": "meeting.md",
"fileMode": "NORMAL"
}
],
"filesDeleted": [],
"filesUpdated": []
}
To create a commit that makes changes to files named file1.py
and file2.txt
, renames a file from picture.png
to image1.png
and moves it from a directory named pictures
to a directory named, images
, and deletes a file named ExampleSolution.py
in a repository named MyDemoRepo
on a branch named MyFeatureBranch
whose most recent commit has an ID of 4c925148EXAMPLE
:
aws codecommit create-commit --repository-name MyDemoRepo
--branch-name MyFeatureBranch
--parent-commit-id 4c925148EXAMPLE
--author-name "Saanvi Sarkar
"
--email "saanvi_sarkar@example.com
" --commit-message "I'm creating this commit to update a variable name in a number of files.
"
--keep-empty-folders false --put-files '{"filePath": "file1.py
", "fileMode": "EXECUTABLE
", "fileContent": "bucket_name = sys.argv[1] region = sys.argv[2]
"}'
'{"filePath": "file2.txt
", "fileMode": "NORMAL
", "fileContent": "//Adding a comment to explain the variable changes in file1.py
"}' '{"filePath": "images/image1.png
",
"fileMode": "NORMAL
", "sourceFile": {"filePath": "pictures/picture.png
", "isMove": true}}' --delete-files filePath="ExampleSolution.py
"
Note
The syntax for the --put-files segment varies depending on your operating system. The above example is optimized for Linux, macOS, or Unix users and Windows users with a Bash emulator. Windows users at the command line or in Powershell should use syntax appropriate for those systems.
If successful, this command returns output similar to the following:
{
"commitId": "317f8570EXAMPLE",
"treeId": "347a3408EXAMPLE",
"filesAdded": [
{
"absolutePath": "images/image1.png",
"blobId": "d68ba6ccEXAMPLE",
"fileMode": "NORMAL"
}
],
"filesUpdated": [
{
"absolutePath": "file1.py",
"blobId": "0a4d55a8EXAMPLE",
"fileMode": "EXECUTABLE"
},
{
"absolutePath": "file2.txt",
"blobId": "915766bbEXAMPLE",
"fileMode": "NORMAL"
}
],
"filesDeleted": [
{
"absolutePath": "ExampleSolution.py",
"blobId": "4f9cebe6aEXAMPLE",
"fileMode": "EXECUTABLE"
},
{
"absolutePath": "pictures/picture.png",
"blobId": "fb12a539EXAMPLE",
"fileMode": "NORMAL"
}
]
}
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4