هذه الصفحة غير متوفرة حاليًا بلغتك المحلية. نحن نعمل جاهدين على إضافة المزيد من اللغات. شاكرين تفهمك ودعمك المستمر لنا.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

Creating a Commit

Updated on 2025-01-14 GMT+08:00

Function

This API is used to commit multiple files in different directories at a time. If the directory does not exist, the system automatically creates a directory. The forcible overwrite option is supported. When the forcible overwrite flag is set to true, the conflict is ignored and the configuration is forcibly committed.

URI

POST /v2/projects/{repo_id}/repository/commits

Table 1 Path parameters

Parameter

Mandatory

Type

Description

repo_id

Yes

Integer

Explanation:

Repository short ID.

Constraints:

Mandatory

Range:

0–2147483647

Default value:

None

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

Explanation:

User token. It can be obtained by calling the IAM API used to obtain a user token. The value of X-Subject-Token in the response header is the user token.

Constraints:

Mandatory

Range:

1–100,000 characters.

Default value:

None

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

branch

Yes

String

Explanation:

Target branch.

Constraints:

Mandatory

Range:

Minimum length: 1

Maximum length: 200

Default value:

None

commit_message

Yes

String

Explanation:

Commit message.

Constraints:

Mandatory

Range:

Minimum length: 0 characters

Maximum length: 2,000 characters

Default value:

None

start_branch

No

String

Explanation:

Name of the new branch.

Constraints:

None

Range:

Minimum length: 1

Maximum length: 200

Default value:

None

actions

Yes

Array of CommitAction objects

Explanation:

Commit processing list.

Constraints:

None

Range:

Minimum length: 1

Maximum length: 100 characters

Default value:

None

author_email

No

String

Explanation:

Committer email address.

author_name

No

String

Explanation:

Committer name

stats

No

Boolean

Explanation:

Whether to include commit statistics. The default value is true.

force

No

Boolean

Explanation:

Whether to overwrite the target branch. When the value is true, overwrite the target branch with a new commit based on start_branch.

Table 4 CommitAction

Parameter

Mandatory

Type

Description

action

Yes

String

Explanation:

Operations to be performed: create, delete, move, update, and chmod.

Constraints:

Mandatory

Range:

create, delete, move, update, chmod

Default value:

None

file_path

Yes

String

Explanation:

Complete path of the file. For example, lib/class.rb.

Constraints:

Mandatory

Range:

None

Default value:

None

previous_path

No

String

Explanation:

Original full path of the file to be moved. For example, lib/class1.rb. This parameter is valid only when the move operation is performed.

Constraints:

None

Range:

None

Default value:

None

content

No

String

Explanation:

File content. This parameter is mandatory for the create and update operations. A move operation that does not specify content retains the existing file content, and any other value of the content overwrites the file content.

Constraints:

None

Range:

None

Default value:

None

encoding

No

String

Explanation:

File encoding: text and base64. The default value is text.

Constraints:

None

Range:

None

Default value:

None

last_commit_id

No

String

Explanation:

Last known commit ID. This parameter is valid only when the update, move, or delete operation is performed.

Constraints:

None

Range:

None

Default value:

None

execute_filemode

No

Boolean

Explanation:

Enable or disable the execution mode of a file. This parameter is valid only when the chmod operation is executed.

Constraints:

None

Range:

None

Default value:

None

Response Parameters

Status code: 200

Table 5 Response body parameters

Parameter

Type

Description

error

Error object

Explanation:

Response error code.

result

CreateCommitResponseBody object

Explanation:

Response result.

status

String

Explanation:

Response status of the API.

Range:

  • success: The API call is successful.
  • failed: The API call failed.
Table 6 Error

Parameter

Type

Description

code

String

Explanation:

Error code.

Range:

Max. 100 characters in the error code format.

message

String

Explanation:

Error message.

Range:

None

Table 7 CreateCommitResponseBody

Parameter

Type

Description

id

String

Explanation:

SHA ID of a commit.

short_id

String

Explanation:

Short SHA ID of a commit.

title

String

Explanation:

Commit title.

author_name

String

Explanation:

Author.

author_email

String

Explanation:

Author email.

committer_name

String

Explanation:

Committer.

committer_email

String

Explanation:

Committer email.

created_at

String

Explanation:

Creation time.

message

String

Explanation:

Commit message.

parent_ids

Array of strings

Explanation:

Parent commit ID.

committed_date

String

Explanation:

Commit time.

authored_date

String

Explanation:

Author commit time.

stats

stats object

Explanation:

Statistics.

Table 8 stats

Parameter

Type

Description

additions

Integer

Explanation:

Number of lines added in changes.

deletions

Integer

Explanation:

Number of lines deleted in changes.

total

Integer

Explanation:

Total number of changed lines.

Example Requests

POST https://{endpoint}/v2/projects/859341/repository/commits

{
  "branch" : "master",
  "commit_message" : "some commit message",
  "actions" : [ {
    "action" : "create",
    "file_path" : "test001.txt",
    "content" : "some content"
  } ]
}

Example Responses

Status code: 200

OK

{
  "result" : {
    "id" : "85a0a9d5c6e43bc9c3e443ac01f789e24eeef02b",
    "title" : "some commit message",
    "message" : "some commit message",
    "short_id" : "85a0a9d5",
    "author_name" : "repo",
    "author_email" : null,
    "committer_name" : "repo",
    "committer_email" : null,
    "created_at" : "2021-09-26T03:44:51.000Z",
    "parent_ids" : [ "5c114bb316dff4d4a046e09a5c44c816f2433140" ],
    "committed_date" : "2021-09-26T03:44:51.000Z",
    "authored_date" : null,
    "stats" : {
      "additions" : 1,
      "deletions" : 0,
      "total" : 1
    }
  },
  "status" : "success"
}

Status Codes

Status Code

Description

200

OK

Error Codes

See Error Codes.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback