简体   繁体   English

如何在我的本地未暂存更改中从Github PR视图显示差异更改?

[英]How Do I show diff changes from the Github PR view in my local unstaged changes?

When I'm working on a PR, I often like to unstage all changes I've ever made in the branch, so I can see every file modified in a diff view locally. 在进行PR时,我经常想取消对分支中所做的所有更改的暂存,因此可以在diff视图中本地查看每个文件。

For example, I have a PR in Github to merge foo-branch into origin/master 例如,我在Github中有一个PR,可以将foo-branch合并到origin/master

I know I can use git reset origin/master to move all changes from origin/master into my unstaged changes, but the staged changes will include files that have changed upstream, but I've not yet merged into foo-branch using git merge origin/master . 我知道我可以使用git reset origin/master将所有更改从origin/master移到未暂存的更改中,但是暂存的更改将包括上游已更改的文件,但我尚未使用git merge origin/master合并到foo-branch git merge origin/master

I don't want to have to constantly keep merging origin/master into foo-branch to get accurate changes showing up via git reset origin/master , and Github seems to handle this fine, and only show me relevant files in the diff tab. 我不想一直不断地将origin/master合并到foo-branch以通过git reset origin/master显示准确的更改,而Github似乎可以解决这一问题,并且只在diff选项卡中显示相关文件。

How can I use git reset to only unstage relevant files? 如何使用git reset来仅取消git reset相关文件?

My desired workflow looks like this: 我想要的工作流程如下所示:

  • make some changes, push to a branch foo-branch 进行一些更改,将其推送到分支foo-branch
  • open a PR against master in Github 打开一个PR对master在Github上
  • some changes were requested, so then I move all my changes into unstaged via git reset origin/develop 请求了一些更改,因此我将所有更改通过git reset origin/develop移入未git reset origin/develop
  • make changes, then do git reset origin/foo-branch to get only my changes since my last commit on the branch 进行更改,然后执行git reset origin/foo-branch仅获取自上次在分支上提交以来的更改
  • git commit ... and git push origin HEAD git commit ...git push origin HEAD

What Github is showing you is the diff against your branch's merge-base , ie the most recent commit that is in master that is a parent of your branch HEAD . Github向您显示的是与分支的merge-base的差异,即master中最新的提交,该提交是分支HEAD的父级。 See the manpage on merge-base here 在此处查看关于merge-base的手册

You'd use: 您将使用:

git reset $(git merge-base origin/master HEAD)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 我如何查看未跟踪、未暂存、暂存和已提交的更改与遥控器的差异? - How do I see a diff from untracked, unstaged, staged and committed changes all against the remote? 如何从GitHUB到本地计算机进行更改? - How do I get changes from GitHUB to my local machine? 如何丢弃 Git 中的未分级更改? - How do I discard unstaged changes in Git? 如何使本地更改显示在github存储库中? - How do I make my local changes show up to github repository? git 说我有未暂存的更改,但我没有显示它们 - git says I have unstaged changes but I do not show them 如何在不删除更改的情况下用GitHub中的文件覆盖本地目录中的文件? - How do I overwrite files in my local directory with files from GitHub without erasing changes? 在我的第一次提交中,我无法推送更改,因为我的 github 中已经有.gitignore 和 README.md,与本地不同 - In my first commit I am unable to push the changes as i already have .gitignore and README.md in my github,diff from local Git 区分所有本地更改,无论哪个提交或暂存/未暂存 - Git diff all local changes, regardless which commit or staged/unstaged 如何还原已提交的行以成为未分阶段的更改 - How do I revert committed lines to become unstaged changes 如何查看最后一次拉到github中我的本地文件的更改? - How to view changes made by last pull to my local files in github?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM