Skip to content
This repository was archived by the owner on Mar 10, 2024. It is now read-only.
This repository was archived by the owner on Mar 10, 2024. It is now read-only.

Merge PR 的一点实践 #55

@ifyour

Description

@ifyour

当某个项目收到来自网友贡献 PR 时,如何验证它的变更是否生效?或者说不破坏当前 master 分支的功能。(没有 CI 自动化测试的时候)

就目前来看,这个工作流应该是这样:

网友

  1. Fork 该项目
  2. 切到 Fork 的项目里,新起分支,比如修复了某 bug,新起分支 patch-bug-fix
  3. 发起 PR

项目 owner

  1. review code
  2. 切到该分支 patch-bug-fix,并设置上游仓库 (1)
  3. 本地验证 ok,merge master

(1) 重点在这里了,设置上游分支关联:

git pull
git checkout patch-bug-fix
git branch --set-upstream-to=origin/patch-bug-fix patch-bug-fix
git pull
# 验证最新的代码 balabala~

第一次切到这个新分支,都需要设置关联的。来配置一个快捷方式吧:

# alias
set-upstream = !git branch --set-upstream-to=origin/`git symbolic-ref --short HEAD`

👇 下次碰到这个提示的时候,只需要执行一下 set-upstream 即可。

There is no tracking information for the current branch.
    Please specify which branch you want to merge with.
    See git-pull(1) for details

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream develop origin/<branch>

Metadata

Metadata

Assignees

No one assigned

    Labels

    draftquickly notes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions