如何预览git-pull而不做提取? [英] How to preview git-pull without doing fetch?

查看:133
本文介绍了如何预览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会在其余的提交中合并。

更新:我不完全确定你为什么想要避免使用git fetch。所有的git fetch都会更新远程分支的本地副本。此本地副本与您的任何分支没有任何关系,并且与未提交的本地更改没有任何关系。我听说有人在cron作业中运行git fetch,因为它非常安全。


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而不做提取?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆