使用Git如何查找本地和远程之间的变化 [英] Using Git how do I find changes between local and remote

查看:799
本文介绍了使用Git如何查找本地和远程之间的变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


  1. 使用Git时,如何查找哪些更改我在本地提交了,但尚未推送到远程分支?我正在寻找类似于Mercurial命令的东西 hg outgoing

  2. 使用Git时,在我进行拉动之前,我能找到远程分支有哪些变化吗?我在寻找类似于Mercurial命令 hg incoming 的东西。


$ b $第二:有没有办法看看有什么可用的,然后樱桃选择我想要拉的变化?

解决方案

Git不能通过网络发送这种信息,如Hg可以。但是你可以运行 git fetch (这更像是 hg pull hg fetch <

因此,如果你有一个名为 master的分支,你可以从远程服务器获取新的提交。 c>和一个名为 origin 的远程,在运行 git fetch 之后,还应该有一个名为起源/主。然后,您可以获得 master 需要成为的超集的所有提交的 git log 原始/主通过做 git log master..origin / master



我的一位朋友David Dollar创建了几个git shell脚本来模拟 hg incoming /传出。你可以在 http://github.com/ddollar/git-utils 找到它们。


Here are two different questions but I think they are related.

  1. When using Git, how do I find which changes I have committed locally, but haven't yet pushed to a remote branch? I'm looking for something similar to the Mercurial command hg outgoing.

  2. When using Git, how do I find what changes a remote branch has prior to doing a pull? I'm looking for something similar to the Mercurial command hg incoming.

For the second: is there a way to see what is available and then cherry-pick the changes I want to pull?

解决方案

Git can't send that kind of information over the network, like Hg can. But you can run git fetch (which is more like hg pull than hg fetch) to fetch new commits from your remote servers.

So, if you have a branch called master and a remote called origin, after running git fetch, you should also have a branch called origin/master. You can then get the git log of all commits that master needs to be a superset of origin/master by doing git log master..origin/master. Invert those two to get the opposite.

A friend of mine, David Dollar, has created a couple of git shell scripts to simulate hg incoming/outgoing. You can find them at http://github.com/ddollar/git-utils.

这篇关于使用Git如何查找本地和远程之间的变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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