You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac Git新手求助:本地合并development分支并创建无冲突GitHub PR

Step-by-Step Guide to Sync Your Feature Branch & Push for a Conflict-Free PR (Mac Git User)

Hey there, fellow Mac Git user! Let’s walk through this process step by step to get your feature branch prepped for a clean pull request. Since you’ve already committed all your local changes, we’re good to jump right in.

1. Confirm You’re on Your Feature Branch

First, make sure you’re working in the right branch. Run this command to switch to your feature branch (if you aren’t already there):

git checkout feature/my-feature-1

To double-check which branch is active, use:

git branch

Your current branch will be marked with an asterisk (*).

2. Update Your Local development Branch

Before merging, we need to pull the latest changes from the remote development branch to your local copy. This ensures you’re merging the most up-to-date code:

git checkout development
git pull origin development

This syncs your local development branch with what’s live on GitHub.

3. Merge Updated development into Your Feature Branch

Switch back to your feature branch and merge the fresh development changes into it:

git checkout feature/my-feature-1
git merge development

4. Resolve Merge Conflicts (If They Pop Up)

If Git spots conflicting code between your feature branch and development, it’ll pause the merge and list the files with conflicts. Here’s how to fix them on Mac:

  • Use a visual merge tool (recommended): Run git mergetool – this will open Mac’s built-in opendiff tool (or any other merge tool you’ve configured). It shows your branch’s changes on the left, development’s on the right, and lets you pick which lines to keep (or combine them manually).
  • Manual editing: Open the conflicting file in your code editor. Look for markers like:
    <<<<<<< HEAD
    // Your feature branch's code
    =======
    // development branch's code
    >>>>>>> development
    
    Edit the file to resolve the conflict, then delete the marker lines. Save the file when done.

Once you fix a conflicted file, stage it with:

git add <path-to-conflicted-file>

Repeat this for all conflicted files. When everything’s staged, finish the merge with:

git commit

Git will auto-generate a merge commit message – you can keep it or tweak it to add context, then save and close the editor to finalize the commit.

Pro tip: If you get stuck and want to cancel the merge entirely, run git merge --abort.

5. Push Your Feature Branch to GitHub

Now that your feature branch is synced with development and conflict-free, push it to the remote repository. If this is your first time pushing this branch, use:

git push --set-upstream origin feature/my-feature-1

The --set-upstream flag links your local branch to the remote one, so future pushes can just use git push.

If you’ve pushed this branch before, a simple git push will work.

6. Create a Conflict-Free PR on GitHub

Head over to your repository on GitHub. You’ll see a prominent banner prompting you to "Compare & pull request" for your newly pushed branch. Click that, then:

  • Set the base branch to development
  • Set the compare branch to feature/my-feature-1
  • Review the changes to confirm everything looks right (since you resolved conflicts locally, GitHub should show "No conflicts")
  • Add a clear title and description for your PR, then click "Create pull request"

That’s it! Your PR is ready for review, with no conflicts to slow things down.


内容的提问来源于stack exchange,提问作者hotmeatballsoup

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.22 09:44:20