跳到主要内容

Online Operations on Branches

Branch functionality is a way to create, edit, and test code changes without affecting the main codebase, allowing developers to create, edit, and test new features without impacting the primary code.

A branch is a copy of the repository that allows developers to work in an isolated environment and merge changes back into the main branch upon completion. Whether you are an individual developer or part of a team, GitCode’s branch functionality provides powerful tools for code management and collaboration to help you better build and maintain software projects. This makes it easier for teams to collaborate, develop new features, and solve problems.

The branch functionality offers the following core features:

  • Independent Development: Creating a branch allows developers to work in an isolated environment without affecting the main code.
  • Multi-branch Collaboration: Multiple developers can simultaneously create and edit branches, then merge changes back into the main branch.
  • Version Control: Branches allow tracking the history of changes for different features or fixes.
  • Branch Management: GitCode provides tools to view, compare, and manage all branches within the repository.
提示
  1. When creating a new repository, there is usually a default branch named main that serves as the primary development line.
  2. Developers can create new branches to develop specific features or fix bugs without affecting the main branch.
  3. Once development is complete, changes from the branch can be merged back into the main branch or another branch.

Branch List


  1. On the project homepage, click "Branches" to enter the branch list page.

    image-20241226152256359

  2. The branch list page displays all branches in the project, where you can perform operations such as creating new branches, deleting branches, and setting protected branches.

    image-20241226152319444

Creating a New Branch


  1. First, go to the branch list page.
  2. Click "+ New Branch" to expand the new branch panel.
  3. In the pop-up dialog, select which existing branch to create the new branch from, input the name of the new branch, and fill in the description information for the newly created branch.
  4. Click the "Confirm" button to create the new branch.

image-20250115111728314

Switching Branches


Switching branches allows you to view file contents under different branches. On the project homepage, click the current branch name to expand the branch options and select a branch to switch to.

image-20241226152451139

Deleting Branches


提示

The main branch (default branch) cannot be deleted.

  1. First, go to the branch list page.
  2. On the right side of non-default branches, there is a delete icon. Click it and confirm to delete the branch.

image-20241226152558604

Merging Branches


The branch merging feature allows you to integrate code changes from different branches into the main branch or other branches, enabling collaborative development and code management. This relies on the Pull Requests functionality. For more information on creating Pull Requests, see Creating Pull Requests.

Best Practices


Here are the best practices for using GitCode's branch functionality:

  • Use clear branch names to better understand the purpose of each branch.
  • Regularly merge the main branch into your branch to stay up-to-date with the latest code.
  • Conduct code reviews to ensure the quality of merged changes.
  • Use branches for independent feature development, bug fixes, and experimental work.

By using branches effectively, you can more efficiently manage the development process of your project and improve maintainability. GitCode provides an intuitive interface and tools to help you easily create, switch, and delete branches, thereby promoting team collaboration and project progress.