0

I'm trying to see the latest commits on branches that were not pushed to a specific branch (dev in my case)

So far what I've done is git checkout dev

and then git branch -r --no-merge

I got a list of branches that were not merged to dev, correct? Now I'm trying to get the date of the latest commit for each of those branches. I've tried pipping git branch -r --no-merge into variations of git log --branches but to no avail.

Momin
  • 3,200
  • 3
  • 30
  • 48
teatime
  • 1
  • 1
  • 1
    "Pushed" and "merged" are quite different things. In any case, the last commit on any given branch is simply the commit to which the branch name points. Each commit has *two* date stamps, though, and both date stamps are completely up to whoever makes the commit, so it's possible that the date stamps on a later commit are earlier than the date stamps on an earlier commit, or that the author date of commit X is last year while the commit date of the same commit is next year, for instance. So you definitely need to re-specify your actual problem. – torek May 08 '17 at 07:32
  • I'm trying to see all the branches that were not pushed to branch dev and their latest change date. – teatime May 08 '17 at 07:41
  • 1
    The thing is, branches don't really *have* change dates (but see reflogs). Meanwhile, you can't tell what was *pushed* from what *you* have *now*, because the verb "to push" means "to copy and hand off to someone else". If you didn't keep track of what you copied and handed off to someone else at the time you copied it and handed it off, you can't tell what you copied and handed off. Looking at what you have now doesn't give you that information. It's like looking at your driver's license now to see if you let a traffic cop see it last week. – torek May 08 '17 at 07:45
  • Try `git fetch origin ;git log FETCH_HEAD..`. The output is the commits that are on the local branch but not on the specific branch yet. – ElpieKay May 08 '17 at 08:37
  • Thanks for the answers, I'm learning a lot. What I'm trying to do now is get the latest commit date for each branch returned from git branch -r --no-merge These are not local branches btw. – teatime May 08 '17 at 09:20
  • This is the answer that helped me: http://stackoverflow.com/a/18767922/1132861 I've had to modify the command to show only branches that weren't merged by adding --no-merge and the -r flag for remote branches, and removing the color flag, since I wasn't really interested in colors. git branch -vvr --no-merge | while read; do echo -e $(git log -1 --format=%ci $(echo "_$REPLY" | awk '{print $2}' | perl -pe 's/\e\[?.*?[\@-~]//g') 2> /dev/null || git log -1 --format=%ci)" $REPLY"; done | sort -r | cut -d ' ' -f -1,4- – teatime May 09 '17 at 07:24

0 Answers0