fle*_*len 5 git command-line github pull-request
我收到了一个拉取请求,我想通过命令行批准它(即,不使用浏览器登录 Github 并使用 GUI)。此 PR 对分支进行更改。
这是我尝试过的:
# First I go to the correct branch:
git checkout branch-to-be-modified
# Then I pull the changes made by the person who's contributing with the PR:
git pull https://github.com/my-contributor/code.git his-branch
# I then run `git status`, but it shows me nothing
git status
# Outputs:
# > On branch branch-to-be-modified
# > nothing to commit, working tree clean
Run Code Online (Sandbox Code Playgroud)
如何通过命令行接受 Github 拉取请求?
我还需要做什么,我应该做吗git push origin branch-to-be-modified?
这应该很容易,但我找不到此信息。非常感谢您提供任何线索
您应该要求 GitHub 合并所述拉取请求:这将是“接受”它。
您可以使用官方 GitHub 客户端从命令行执行此操作gh
gh pr merge <number>
Run Code Online (Sandbox Code Playgroud)
但这假设您首先登录(例如,使用像您的PAT :这样的令牌gh auth login --with-token < mytoken.txt)。
同样,从命令行,不直接使用 GitHub Web。
但是,如果您想接受而不合并,即在有多个审阅者的情况下,该怎么办?
那么你需要使用gh pr review:
gh pr merge <number>
Run Code Online (Sandbox Code Playgroud)
这样,您就可以批准拉取请求,表明您对更改感到满意,同时仍保留开放状态以供其他审阅者在合并之前提供反馈。
而且,如果您是 GitHub 上团队项目的一部分,您可能设置了受保护的分支,这些分支需要多次审查才能合并拉取请求。
在此类设置中,可以使用 GitHub CLI 完成单独批准,如上所示,并且拉取请求只有在收到所需数量的批准后才能合并。