git: list remote changes

时间秒杀一切 提交于 2019-12-25 01:47:23

问题


I have a git remote "mine" (happens to be a github fork) that has managed to get ahead by 2 commits. My local master branch is ahead of it by 244 commits (pulled from the original gitub repo). As a result, pushing to "mine" is not fast-forward.

How can I list the 2 commits by which "mine" is ahead?


回答1:


Your question is a little unclear, but it sounds like you want to list the commits on the remote branch that don't exist in your local branch yet. This is simply accomplished using a commit range ..:

# Get the most recent updates from the remote
git fetch <remote>

# List all commits that are in <remote>/<branch> but not in your local <branch>
git log --oneline <branch>..<remote>/<branch>

Documentation

From the official Linux Kernel git log documentation:

<since>..<until>

Show only commits between the named two commits. When either <since> or <until> is omitted, it defaults to HEAD, i.e. the tip of the current branch. For a more complete list of ways to spell <since> and <until>, see gitrevisions(7).

See Also

  • Pro Git § 6.1 Git Tools - Revision Selection - Commit Ranges


来源:https://stackoverflow.com/questions/24182162/git-list-remote-changes

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!