how to merge branches in github, cancel merge github , branch github

Create a Branch in GitHub and Merge Safely

Learning how to create a branch in GitHub is the first step. However, mastering how to merge branches in GitHub safely is just as critical for every branch GitHub의 workflow. So, in this post, we’ll walk you through the entire process, starting with how to create a branch in GitHub and then showing you how to merge branches in GitHub safely. We’ll also cover how to cancel a merge if you find any problems, and finally, how Xygeni can help you catch every issue before it gets into your main branch.

단계별로 살펴보겠습니다.

1. How to Create a Branch in GitHub the Right Way

Every secure workflow starts when you create a branch in GitHub. It allows developers to isolate features, fixes, or experiments without impacting the production code.

To create a branch in GitHub:

1. Navigate to your repository

2. Click the branch selector dropdown

how to merge branches in github, cancel merge github and branch github

3. Type the name of your new branch

4. 클릭 Create branch

how to merge branches in github, cancel merge github and branch github

From here, your new branch is ready to go. You can now push code, collaborate on changes, and eventually open a pull request. Although this is a basic GitHub action, it sets the stage for secure development.

Importantly, every time you create a branch in GitHub, it should be part of a repeatable and protected workflow.

2. 스캔 Pull Requests Automatically Before You Merge

When you create a branch in GitHub and prepare for review, the next step is understanding how to merge branches in GitHub securely. Each branch GitHub push should trigger automated checks. But before merging, it is essential to 확인 the code does not introduce vulnerabilities. A single unsafe commit can expose your application, leak secrets, or break critical infrastructure.

Merging code into your main branch is a high-impact operation. Without proper checks in place, it can lead to serious consequences such as:

This is where Xygeni makes a real difference

사용하여 GitHub 액션, you can trigger automated Xygeni scans whenever a developer opens a pull request into a protected branch. A protected branch in GitHub is one that requires specific checks or approvals before changes are allowed to merge.

Xygeni analyzes the latest execution of the pull request 워크플로우 to validate the security posture of the proposed changes. This includes checking for issues in the code, dependencies, secrets, and CI/CD 구성. The full branch is not re-scanned, but the most recent workflow result is used to enforce policies and block unsafe merges.

These scans validate that the code is secure and production-ready. They detect:

통합 these checks early ensures that every time you create a branch in GitHub and prepare to merge, you do it with 완전한 가시성과 제어.

Here’s a simplified setup:

on:   pull_request:     branches: [ main ] jobs:   xygeni-scan:     runs-on: ubuntu-latest     steps:       - name: Checkout         uses: actions/checkout@v3       - name: Xygeni Scanner         uses: xygeni/xygeni-action@3.2.0         with:           token: ${{ secrets.XYGENI_TOKEN }}

3. Block Insecure Merges with Guardrails

Guardrails, ensure that when you create a branch in GitHub or attempt how to merge branches in GitHub, only safe changes reach your main branch GitHub setup. Xygeni gives you full control over what gets merged. You can define precise rules tailored to your security policies and risk tolerance. For example:

  • Block if a critical secret is found (e.g., AWS keys, tokens)
  • Fail the build 만약 new high-risk open source package is introduced
  • 거절 pull requestsmodify sensitive paths 처럼 .github/workflows/, infrastructure/secrets.env
  • Prevent merges 만약 downgrade reintroduces 알려진 취약점
  • 블록 CI/CD 구성 변경 unless properly labeled
  • Stop merges if SAST detects high or 중요한 문제
  • Apply stricter Guardrails on production branches while keeping flexibility in development

These rules act as automated gatekeepers. They help your team merge only what’s secure,  no surprises, no manual reviews, no last-minute firefighting.

Example Guardrail rule:

guardrail block_critical_secrets   on secrets   when severity = critical   then @fail()

Visual Feedback in the Dashboard

how to merge branches in github, cancel merge github and branch github

To ensure full visibility, Xygeni shows the result of the latest evaluation of the Guardrail status.

  • 가장 먼저, a green icon means all policies passed.
  • 대조적으로, a red icon signals that one or more Guardrail conditions were violated.

As a result, both developers and security teams gain immediate insight into why a merge was blocked, without digging into CI logs.

Real Example from the Dashboard:

For example, Let’s say a repository has no protected branches, a common misconfiguration that allows developers to push commits without verification. That’s a serious risk.

Xygeni automatically detects and flags this as a signed_commits issue under the CI/CD 범주. 그만큼 dashboard 하이라이트:

  • 심각도 : 높음
  • 유형: 서명 Commits
  • 설명 : The repository has no protected branches
  • 상태 : 엽니다

Therefore, with this context-rich feedback, teams can quickly identify the risk, understand its impact, and take corrective action,  all from the Xygeni UI.

맞춤형 Enforcement Behavior

You’re always in control. Choose how strict Guardrails 해야한다:

  • --fail-on=critical: Block merges only on severe findings
  • --never-fail: 달리기 Guardrails in dry-run mode to test policies before enforcing

So next time you create a branch in GitHub, your Guardrails are already there, protecting your pipeline and enforcing your policies automatically.

How Do I Know If a GitHub App Is Safe?

Learn how to evaluate GitHub Apps before installing them.

관련 읽기 :

4. Cancel Merge in GitHub Automatically When Risks Are Found

If risks are detected, the merge is canceled. This safeguard protects every branch GitHub project and enforces best practices on how to merge branches in GitHub.

Xygeni integrates directly into GitHub’s UI. When a risk is found:

  • GitHub shows the check as failed
  • GitHub’s protections prevent the merge
  • The merge queue skips insecure code

Whether it’s a secret, CVE, or dangerous CI/CD pattern, the result is the same: the merge is canceled in GitHub and flagged for review.

You can also view detailed results in Xygeni:

  • The security status of each branch
  • Why a merge was blocked
  • Complete scan history
  • Guardrail status shown via green (pass) or red (fail) icons in the project page

This visual feedback makes it easy for developers and security teams to take action with confidence. And when you need deeper context, each issue links to documentation with severity, tags, location, and mitigation guidance.

Tldr Merge Only What’s Safe

To summarize, here’s how to merge securely after you create a branch in GitHub:

  • Create a branch in GitHub through the UI
  • Trigger automatic scans with every pull request Xygeni와 함께 
  • Block insecure merges using Guardrails
  • Use server-side audit policies for deeper control
  • Cancel merge in GitHub when something fails
  • Visualize all results in Xygeni’s dashboard

For additional best practices on repository protection, read our GitHub 보안 FAQ: 모든 개발자가 알아야 할 사항.

Although merging is a basic operation, doing it securely requires real visibility and automation. With Xygeni, you don’t just merge code, you merge trust.

Protect Every GitHub Branch with Confidence

A single overlooked issue in a pull request can compromise your main branch. Traditional scanners often run too late, miss critical risks, or fail to enforce meaningful policies.

That is why protecting your GitHub branches takes more than just scanning.

Xygeni provides real enforcement. 때 pull request targets a protected branch, Xygeni analyzes the latest execution of your CI/CD workflow. It does not re-scan the entire branch. Instead, it evaluates the most recent results to check for security issues in code, dependencies, secrets, and workflow configurations. You are not just alerted. You are protected.

차이점:

  • Full-context validation: Guardrails enforce policy using rich context like severity, exploitability, and branch metadata.
  • Built-in GitHub integration: Everything from scanning to enforcement runs natively within your GitHub workflows, with no need for custom scripts or glue code.
  • Server-side audits: 서버 측 Guardrails validate the results after upload, adding a second layer of control outside the pipeline.

Instead of relying on your CI setup to catch everything, Xygeni applies automated, policy-based decisions before anything reaches your main branch.

Although merging is a basic operation, doing it securely requires real visibility and automation. With Xygeni, you don’t just protect your repos,  you protect every branch GitHub with confidence.

sca-tools-software-composition-analysis-tools
소프트웨어 위험을 우선순위화하고, 해결하고, 보호하십시오.
무료 계정을 만드세요.
신용 카드가 필요하지 않습니다.

소프트웨어 개발 및 제공을 안전하게 보호하세요

Xygeni 제품군과 함께