2

So when I create and switch to a new non MASTER branch, I can no longer see the list of unpushed commits. I guess that makes sense, as I am on a branch and MASTER is now my upstream (instead of github)?

Still, I would like to be able to see something about all the commits I have made today.

How do I view all the commits I have made on the local branch, that haven't yet been merged with MASTER?

Ok, given that, how do I configure magit so that whenever I am on a branch and I enter M-x magit-status, I see a list of unmerged commits that I have made on this branch? Something that looks similar to how when I am on MASTER, and I enter M-x magit-status, I get a list of all unpushed commits?

The basically empty magit-status buffer makes me nervous when I am on a branch. :)

juanleon
  • 8,552
  • 28
  • 37
Stephen Cagle
  • 12,627
  • 14
  • 49
  • 83
  • Creating and switching to a new branch does absolutely nothing to your upstream. `master` is *not* your upstream at that point, and as far as I know Git has no notion of "upstream branches". As juanleon mentions below, the reason you're not seeing unpushed commits is because your new branch is not set to track a remote branch. – Chris Jul 03 '14 at 12:43
  • 1
    @Chris please turn this into an answer instead of a comment. – tarsius Jul 28 '14 at 20:20

2 Answers2

2

If your branch is tracking a remote branch, you will automatically have that.

If not, and you are interested in master, you can use code below. This code will add your magit-status a new section "Unmerged commits" whenever you have commits not in master.

(eval-after-load 'magit
  '(progn
     (defun magit-insert-unmerged-commits ()
       (magit-git-insert-section (unmerged "Unmerged commits:")
                                 (apply-partially 'magit-wash-log 'unique)
                                 "log" "--format=format:%h %s" "master..HEAD"))

     (magit-define-section-jumper unmerged  "Unmerged commits")

     (add-hook 'magit-status-sections-hook 'magit-insert-unmerged-commits t)))

You will need magit 2.0 or greater.

If you are not interested commits not merged to master, but to the local branch where you branched your branch, you will need further customization of above code (I hardcoded "master").

juanleon
  • 8,552
  • 28
  • 37
0

If you just want to see unpushed commits, add

(setq magit-set-upstream-on-push t)

to your initialization file and magit will ask you if you want to set upstream when pushing -- just type "yes" when you push for the first time and you won't be asked again. You'll then see the unpushed commits.

Documentation for magit-set-upstream-on-push:

Whether `magit-push' may set upstream when pushing a branch. This only applies if the branch does not have an upstream set yet.

nil don't use --set-upstream.

t ask if --set-upstream should be used.

`dontask' always use --set-upstream.

`refuse' refuse to push unless a remote branch has already been set.

Community
  • 1
  • 1
TooTone
  • 6,741
  • 3
  • 29
  • 57