Flavius
Flavius

Reputation: 13816

See what git fetch displayed last time

After I have fetched the remote data (git-fetch), git is friendly enough to tell me the SHAs on each branch, old..new, but if I work a lot in the console, I may lose them.

How to display them again?

Of course I could save the output to a file or remember it. These are no options for me.

Upvotes: 4

Views: 287

Answers (2)

sehe
sehe

Reputation: 393064

Edit

From the comments:

To get what just changed on all remote branches, do

git for-each-ref refs/remotes | 
    while read ref type name
    do 
        echo ----- $name
        git log --oneline "$name@{1}..$name@{0}"
    done

Typical output:

----- refs/remotes/sehe.nl/stable
warning: Log for 'refs/remotes/sehe.nl/stable' only has 1 entries.
----- refs/remotes/sehe.nl/testing
4934e92 reviewed INSTALL file as per #1331
----- refs/remotes/sehe.nl/unstable
----- refs/remotes/sehe.nl/xattrs
warning: Log for 'refs/remotes/sehe.nl/xattrs' only has 1 entries.
----- refs/remotes/tobey/maint
6215be7 reviewed INSTALL file as per #1331
----- refs/remotes/tobey/maint-0.6.9
warning: Log for 'refs/remotes/tobey/maint-0.6.9' only has 1 entries.
----- refs/remotes/tobey/master
warning: Log for 'refs/remotes/tobey/master' only has 1 entries.
----- refs/remotes/tobey/testing
4934e92 reviewed INSTALL file as per #1331

Note that, unstable just had no reachable commits between @{1}..@{0}, the branches with warnings had no prior ref value in the log.

Bonus

I prefer to tweak the log as well:

     git log --oneline --graph --left-right --cherry-pick \
            "$name@{1}...$name@{0}"

(note the extra dot in ... (!))

This will show the merge directions, and also show non-linear commit differences; I.e. it works well in showing differences in refs that may have been force-pushed (or pulled)


To get reflog info for all branches, simply

git log -g --oneline --branches

You'll get output similar to:

4934e92 testing@{0}: commit: reviewed INSTALL file as per #1331
6215be7 maint@{0}: commit: reviewed INSTALL file as per #1331
1e5e121 emmanuel@{0}: rebase finished: refs/heads/emmanuel onto f6e2c6c3f9cec0ccf7d96d3edb92f806587adcbc
7b326b9 emmanuel@{1}: branch: Created from rainemu/master e96783e compress@{0}: rainemu/compress: updating HEAD
ff19004 compress@{1}: rebase finished: refs/heads/compress onto f6e2c6c3f9cec0ccf7d96d3edb92f806587adcbc
f6e2c6c unstable@{0}: rebase -i (abort): updating HEAD
6b8f506 unstable@{1}: commit (merge): Merge remote branch 'rainemu/master' into unstable 5327c2f unstable@{2}: merge rainemu/master: Merge made by recursive.
f6e2c6c unstable@{3}: merge emmanuel: Fast-forward
f45ff54 unstable@{4}: merge rainemu/master: Merge made by recursive.
e23fc0b maint@{1}: commit: fix scons warnings dd52720 master-lucid@{0}: commit: lucid 1fb30cf testing@{1}: commit: fix missing split on environment CFLAG
aac7936 unstable@{5}: pull rainemu master: Merge made by recursive.
2c01d7f unstable@{6}: branch: Created from sehe.nl/unstable 927ad7a testing@{2}: branch: Created from sehe.nl/testing
3b32fa7 maint@{2}: branch: Created from sehe.nl/maint 6eaa64f maint-0.6.9@{0}: branch: Created from sehe.nl/maint-0.6.9

Upvotes: 2

sitaram
sitaram

Reputation: 11

git reflog show origin/master seems to work; run it for each branch I guess. I don't think there is a single reflog command to pull data for all branches

Upvotes: 1

Related Questions