Branches

Branches are independent lines of development allowing devs to work on features, fix bugs and test stuff without the risk of disturbing the main line (master branch). With Buddy, you can create, merge and manage branches in a just a few clicks.

Creating a new branch

  1. Go to your project and click the Code tab.
  2. Switch the tab to Branches and click the + icon.
  3. Provide the name, description (optional), and set the starting point from the dropdown menu (branch, tag, or commit).
  4. Click Create new branch to proceed.

Image loading...Creating a new branchCreating a new branch

Success
You can also create a new branch in the Files and Commits tab by clicking the branch name found at the top. Image loading...Navigation dropdown on repository viewNavigation dropdown on repository view

Merging branches

  1. Go to Code tab and switch the tab to Merges.
  2. Click the Merge button on the right and choose the source and target branches:

Image loading...Merging branchesMerging branches

  1. When ready, click Merge now.

Image loading...Branch comparison details before mergeBranch comparison details before merge

Success

What you need to know about merging branches

  • You can merge two branches only if there are no conflicts between them
  • The comparison status shows you the number of commits ahead (green) and behind (red) the selected branch
  • If you do not have permissions to push to the selected branch, you can reate a Merge Request instead

Changing the default branch in the repository

You can change the default branch for the repository in the Branches tab by using the hamburger menu next to the branch's name. This branch will be default when you clone the repository, or when you browse the source in Buddy.

Image loading...Changing the default branchChanging the default branch

Hint
You must have admin permissions to view and change this setting.

Branch permissions

Push permissions allow you to restrict write permissions in a specific branch in the repository. Here’s how:

  1. Go to Code, switch the tab to Branches, and click the branch that you want to restrict.
  2. Enter Permissions tab and select who’s allowed to make pushes.

Image loading...Push permissionsPush permissions

Hint
Users with restricted access will still be able to pull that branch and browse its contents; however, they will not be able to push or merge it remotely or manage its files from the source browser. You have to be an admin to view and change this setting.

Repository backup

You can back up a branch in your repository by adding an SSH command that will trigger the upload of the newest version to a server after every push to that branch. Here’s how:

  1. Execute the following on the server where you want to keep the data:

    bash
    mkdir backup cd backup git clone --mirror repo_url_ssh$$$
  2. Open the project that you want to backup and go to Pipelines
  3. Add a new pipeline in the automatic mode and add the SSH action
  4. Provide the details of your server and set “backup/repo” as the working directory
  5. In the command field type the following:

    bash
    git remote update$

Once you save, the backup will be performed automatically on every push to the branch.

Last update:
Sep 23, 2024