の後で情報を失いたくgit pull
なかったので、 のgit fetch
前にしました。の後に新しい変更をどこで読むことができgit fetch
ますか? ファイルに行きましたFETCH_HEAD
が、大きな数字しかありませんでした。
3 に答える
git fetch origin
by default fetches everything from the remote named "origin" and updates (or creates) the so-called "remote-tracking branches" for that remote. Say, for the remote named "origin" which contain branches named "master" and "feature", running git fetch remote
will result in the remote-tracking branches named "origin/master" and "origin/feature" being updated (or created, if they're not exist). You could see them in the output of git branch -a
(notice "-a").
Now, the usual Git setup is that (some of) your local branches follow certain remote branches (usually same-named). That is, your local "master" branch follows "origin/master" etc.
So, after you fetched, to see what remote "master" has compared to your local "master", you ask Git to show you exactly this:
git log origin/master ^master
which means «all commits reachable from "origin/master" which do not include commits reachable from "master"» or, alternatively
git log master..origin/master
which has the same meaning. See the "gitrevisions" manual page for more info, especially the "Specifying ranges" part. Also see the examples in the git-log manual page
You're free to customize the output of git log
as you see fit as it supports a whole lot of options affecting it.
Note that your local branch might also have commits which the matching remote branch does not contain (yet). To get an overview of them you have to reverse the revisions passed to git log
for (hopefully) obvious reasons.
As usual, it's essential to educate yourself to understand the underlying concepts before starting to use a tool. Please do.
試す
git log --oneline --decorate origin/master
master
これにより、リモートのヘッドからの変更ログが得られますorigin
(必要に応じて、他のリモート ブランチを置き換えることができます)。次のような出力が得られます。
234121 (origin/master) Commit message 5
872373 Commit message 4
623748 Commit message 3
235090 (master) Commit message 2
192399 Commit message 1
マークされたコミット(master)
は、ローカルmaster
ブランチのヘッドです。マークされたコミット(origin/master)
は、リモートのmaster
ブランチのヘッドです。