El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

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
Managed Threat Detection
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
On this page

Show all

Help Center/ CodeArts Repo/ User Guide/ Uploading Code Files to CodeArts Repo/ Creating a Branch and Developing Code in Git Bash

Creating a Branch and Developing Code in Git Bash

Updated on 2024-11-22 GMT+08:00
  1. Go to a local repo directory and open Git Bash. Run the following command to create a branch feature1 based on the master branch and switch to the feature1 branch:

    git checkout -b feature1

  2. The following steps simulate writing the string hello CR to a file named hello_cr.txt.

    echo 'hello CR' > hello_cr.txt

  3. Add all modified files in the current directory to the temporary storage area of Git and prepare to commit them to the version library.

    git add .

  4. Commit the modified code to the local code repo and add a piece of commit information.

    git commit -m 'hello cr'

  5. View the details of the latest commit.

    git log -1

  6. Run the following command to push the local branch feature1 to the origin branch of your remote repo and establish a tracing relationship between the local branch and the remote branch:

    git push --set-upstream origin feature1 
    NOTE:
    • If connect to host ********.com port 22: Connection timed out is displayed in step 6, your network is restricted and you cannot access CodeArts Repo. Contact your local network administrator.
    • If you add the local path to the repository of CodeArts Repo after creating a commit, you cannot change the path of the commit code. You can only delete the file locally or roll back the commit to forcibly commit the code.
    • Check the IP address whitelist. If no whitelist is configured, all IP addresses are allowed to access the repository. If a whitelist is configured, only IP addresses in the whitelist are allowed to access the repository.

  7. Go to the homepage of the repository where a merge request is to be created, choose Merge Requests > Create MR, and select the source and target branches. In the lower part of the page for creating a merge request, you can view the details of the files in the two branches and the commit records of the branch to be merged.
NOTICE:
  • To commit local code to CodeArts Repo, you need to run the git push command. The git commit command only saves the modifications in the local repo. Each commit operation generates a new commit record, recording the modified content, author, and time. The commit operation only saves the code changes to the local repo and does not sync them to the remote repo.
  • When you push code to CodeArts Repo, the message "You are not allowed to push code to protected branches on this project" is displayed. This is because the branch is protected and you do not have the permission to push code to the branch. Solution: Go to the repository details page as the repository owner or project administrator, choose Settings > Policy Settings > Protected Branches, and click to cancel the protection for the branch.
  • The message "src refspec master does not match any" is displayed during code push. The reason is that you do not run the git add and git commit commands to add files from the workspace to the temporary storage area in sequence. Solution: Before running the git push command, run the git add and git commit commands to submit the modified file to the temporary storage area, and then run the push command to push the file to the cloud repository.
  • When you push code to CodeArts Repo, the message "error: failed to push some refs to 'https://codehub" is displayed. The code in the CodeArts Repo is inconsistent with that in the local repo. As a result, the code commit is rejected. Solution: Run the git pull command to pull the code from the remote repository of CodeArts Repo, merge the code with the local repository, and run the git push command to push the code to CodeArts Repo.
  • The git pull command fails to pull code, and the message "Merge branch 'master' of https://codehub/testMaven Please enter a commit message to explain why this merge is necessary" is displayed. The code in CodeArts Repo is different from the code in your local repository. Therefore, when git pull is executed, the remote code will be merged to the local code. The dialog box displayed asks you to confirm the merge and enter a commit message. Solution: See What Can I Do If Code Fails to Be Pulled Using git pull with Error Message "Merge branch'master' of https://xx.com Please Enter a commit"?.
  • If the error message "unable to auto-detect email address" is displayed when you perform step 4, it means the username and email address are not set. You can run the following command to configure your personal information:
    git config --global user.name {your name}
    git config --global user.email {your email address}
  • If the error message " 'origin on' does not appear to be a git repository..." is displayed in step 6, it means the repository name origin does not exist remotely. For details about the solution, see The error message "origin" does not appear to be a git repository..." is displayed when the git push command is executed.
  • If the error message "Not a git respository" is displayed when you perform step 3, the cause is that you are not in the current code repository directory. In this case, run the cd command to go to the repository directory.
  • If the error message "failed to push some refs to '....git'" is reported when you commit a merge request, see Resolving a Merge Request Conflict.
  • In step 6, the message "Connection reset by test port 22 fatal: Could not read from remote repository." is displayed, it means the network is unstable and the request is reset. If this problem occurs occasionally, the network may be faulty.

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback