Coding⏱️ 3 min read📅 2026-06-03

How to Fix: Merge, update, and pull Git branches without using checkouts

Merge, update and pull Git branches without switching branch.

Quick Answer: Use `git merge --no-commit origin/branchB` to merge branch B into your current branch without creating a new commit. Then use `git pull` to update the branch.

In Git, it's common to work on multiple branches and merge changes from one branch to another. However, managing these branches can be tedious, especially when you need to keep a local copy of the branch without merging it first.

🔍 Why This Happens

  • When you use `git checkout` to switch branches, Git updates the current branch pointer to point to a new commit. If you want to keep a local copy of the branch without merging it first, you need to use `git update-ref` or other workarounds.

🚀 How to Resolve This Issue

Method 1: Git Merge, Update, and Pull

  1. Step 1: Run `git merge --no-commit origin/branchB` to create a new merge commit.
  2. Step 2: Run `git update-ref refs/remotes/origin/branchB HEAD` to update the local copy of branch B.
  3. Step 3: Run `git pull --rebase origin/branchB` to rebase your current branch on top of the merged changes.

Method 2: Git Cherry-Pick and Merge

  1. Step 1: Run `git cherry-pick origin/branchB` to create a new commit on your current branch.
  2. Step 2: Run `git merge --no-commit origin/branchB` to create a new merge commit.
  3. Step 3: Run `git pull --rebase origin/branchB` to rebase your current branch on top of the merged changes.

✨ Wrapping Up

By using these methods, you can merge and update branches without switching between them. However, keep in mind that these workarounds might not be as efficient or convenient as simply checking out a branch and merging it.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions