如何预览 git-pull? [英] How to preview git-pull?

查看:17
本文介绍了如何预览 git-pull?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有可能吗?

基本上,有一个远程存储库,我只使用:

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".

推荐答案

在做了一个 git fetch 之后,再做一个 git log HEAD..origin/master 来显示上次共同提交和源的主分支之间的日志条目.要显示差异,请使用 git log -p HEAD..origin/master 显示每个补丁,或使用 git diff HEAD...origin/master(三个点不是二) 显示单个差异.

After doing a git fetch, do a git log HEAD..origin/master to show the log entries between your last common commit and the origin's master branch. To show the diffs, use either git log -p HEAD..origin/master to show each patch, or git diff HEAD...origin/master (three dots not two) to show a single diff.

通常不需要撤消提取,因为执行提取只会更新远程 分支,而不会更新您的 分支.如果您不准备在所有远程提交中进行拉取和合并,您可以使用 git cherry-pick 仅接受您想要的特定远程提交.稍后,当您准备好获取所有内容时,git pull 将合并到其余的提交中.

There normally isn't any need to undo a fetch, because doing a fetch only updates the remote branches 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.

更新:我不完全确定您为什么要避免使用 git fetch.git fetch 所做的只是更新远程分支的本地副本.这个本地副本与您的任何分支都没有任何关系,也与未提交的本地更改没有任何关系.我听说有人在 cron 作业中运行 git fetch 因为它非常安全.(不过,我通常不建议这样做.)

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 the remote branches. 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. (I wouldn't normally recommend doing that, though.)

这篇关于如何预览 git-pull?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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