问题描述
基本上,我有一个远程存储库,只需使用它:
git pull
现在,我想预览一下这拉会改变(差异),而不会触及我身边的任何东西。原因是我拉的东西可能不是好的,我希望别人在使我的存储库变得脏之前修复它。 解决方案
基本上,我有一个远程存储库,只需使用它:
git pull
现在,我想预览一下这拉会改变(差异),而不会触及我身边的任何东西。原因是我拉的东西可能不是好的,我希望别人在使我的存储库变得脏之前修复它。 解决方案
执行 git fetch
后,执行 git log HEAD..origin
以显示日志最后一次常用提交和原始分支之间的条目。要显示差异,请使用 git log -p HEAD..origin
来显示每个补丁,或者使用 git diff HEAD ... origin
(三个点不是两个)来显示单个差异。
通常没有任何需要撤销抓取,因为抓取只会更新远程分支和您的分支机构都不是。如果您不准备在所有远程提交中执行pull和merge操作,可以使用 git cherry-pick
来仅接受所需的特定远程提交。后来,当你准备好获取所有东西的时候,git pull会在其余的提交中合并。
Is it even possible?
Basically, there's a remote repository from which I pull using just:
git pull
Now, I'd like to preview what this pull would change (a diff) without touching anything on my side. The reason is that thing I'm pulling might not be "good" and I want someone else to fix it before making my repository "dirty".
After doing a git fetch
, do a git log HEAD..origin
to show the log entries between your last common commit and the origin branch. To show the diffs, use either git log -p HEAD..origin
to show each patch, or git diff HEAD...origin
(three dots not two) to show a single diff.
There normally isn't any need to undo a fetch, because doing a fetch only updates the remote branch and none of your branches. If you're not prepared to do a pull and merge in all the remote commits, you can use git cherry-pick
to accept only the specific remote commits you want. Later, when you're ready to get everything, a git pull will merge in the rest of the commits.
Update: I'm not entirely sure why you want to avoid the use of git fetch. All git fetch does is update your local copy of a remote branch. This local copy doesn't have anything to do with any of your branches, and it doesn't have anything to do with uncommitted local changes. I have heard of people who run git fetch in a cron job because it's so safe.
这篇关于如何预览git-pull而不做提取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!