How to find out which package was installed from GitHub in my R library?

Use the source. If you examine the code for devtools::session_info() the relevant info seems to be in devtools::package_info(). The code for package_info is:

> getAnywhere("package_info")
A single object matching ‘package_info’ was found
It was found in the following places
  namespace:devtools
with value

function (pkgs = loadedNamespaces(), include_base = FALSE, libpath = NULL) 
{
    desc <- suppressWarnings(lapply(pkgs, packageDescription, 
        lib.loc = libpath))
    not_installed <- vapply(desc, identical, logical(1), NA)
    if (any(not_installed)) {
        stop("`pkgs` ", paste0("'", pkgs[not_installed], "'", 
            collapse = ", "), " are not installed", call. = FALSE)
    }
    if (!include_base) {
        base <- vapply(pkgs, pkg_is_base, logical(1))
        pkgs <- pkgs[!base]
    }
    pkgs <- sort_ci(pkgs)
    attached <- pkgs %in% sub("^package:", "", search())
    desc <- lapply(pkgs, packageDescription, lib.loc = libpath)
    version <- vapply(desc, function(x) x$Version, character(1))
    date <- vapply(desc, pkg_date, character(1))
    source <- vapply(desc, pkg_source, character(1))
    pkgs_df <- data.frame(package = pkgs, `*` = ifelse(attached, 
        "*", ""), version = version, date = date, source = source, 
        stringsAsFactors = FALSE, check.names = FALSE)
    rownames(pkgs_df) <- NULL
    class(pkgs_df) <- c("packages_info", "data.frame")
    pkgs_df
}
<bytecode: 0x000000000e211f50>
<environment: namespace:devtools>

Basically the output from utils::packageDescription() is getting passed to devtools::pkg_source(). So if you want you could just check what the output of packageDescription looks like and write a function to identify if the description flags it as a github package or not. I made a first pass at it although I haven't tested extensively.

isGithub <- function(pkg){!is.null(packageDescription(pkg)$GithubRepo)}

And then to run it on all of our packages we can just list the folders in .libPaths as such

sapply(dir(.libPaths()), isGithub)

Thanks to @Dason, I finally got this to work

Function to find packages installed from GitHub

isGithub <- function(pkg){
    !is.null(packageDescription(pkg)$GithubRepo)
}

Get all packages in my local library

my_lib <- as.data.frame(library()$result, stringsAsFactors=FALSE)

Check which packages are from GitHub

result <- sapply(my_lib$Package, isGithub)
df <- data.frame(package = names(result), github_or_not = result, 
             stringsAsFactors = FALSE)
head(df[df$result == TRUE, ])

     names.result. result
4           bindr   TRUE
5        bindrcpp   TRUE
6        blogdown   TRUE
9          chroma   TRUE
17          dplyr   TRUE
21          editR   TRUE

A little modification that allows you to go through your libraries and determine the source of each including the name of the github repo

library(tidyverse)
#> Registered S3 methods overwritten by 'ggplot2':
#>   method         from 
#>   [.quosures     rlang
#>   c.quosures     rlang
#>   print.quosures rlang
#> Registered S3 method overwritten by 'rvest':
#>   method            from
#>   read_xml.response xml2
allmypackages <- as.data.frame(installed.packages())
allmypackages <- allmypackages %>%
  filter(Priority != "base" | is.na(Priority)) %>%
  select(-c(Enhances:MD5sum, LinkingTo:Suggests)) %>%
  droplevels()

package_source <- function(pkg){
  x <- as.character(packageDescription(pkg)$Repository)
  if (length(x)==0) {
    y <- as.character(packageDescription(pkg)$GithubRepo)
    z <- as.character(packageDescription(pkg)$GithubUsername)
    if (length(y)==0) {
      return("Other")
    } else {
      return(str_c("GitHub repo = ", z, "/", y))
    }
  } else {
    return(x)
  }
}

head(sapply(allmypackages$Package, package_source),60)
#>  [1] "CRAN"                            "CRAN"                           
#>  [3] "CRAN"                            "CRAN"                           
#>  [5] "CRAN"                            "CRAN"                           
#>  [7] "CRAN"                            "CRAN"                           
#>  [9] "CRAN"                            "CRAN"                           
#> [11] "CRAN"                            "CRAN"                           
#> [13] "CRAN"                            "CRAN"                           
#> [15] "CRAN"                            "CRAN"                           
#> [17] "CRAN"                            "CRAN"                           
#> [19] "CRAN"                            "CRAN"                           
#> [21] "CRAN"                            "CRAN"                           
#> [23] "CRAN"                            "CRAN"                           
#> [25] "CRAN"                            "CRAN"                           
#> [27] "CRAN"                            "CRAN"                           
#> [29] "CRAN"                            "CRAN"                           
#> [31] "CRAN"                            "CRAN"                           
#> [33] "CRAN"                            "CRAN"                           
#> [35] "CRAN"                            "CRAN"                           
#> [37] "CRAN"                            "CRAN"                           
#> [39] "CRAN"                            "CRAN"                           
#> [41] "CRAN"                            "CRAN"                           
#> [43] "CRAN"                            "CRAN"                           
#> [45] "Other"                           "R-Forge"                        
#> [47] "CRAN"                            "CRAN"                           
#> [49] "CRAN"                            "CRAN"                           
#> [51] "CRAN"                            "CRAN"                           
#> [53] "CRAN"                            "CRAN"                           
#> [55] "CRAN"                            "CRAN"                           
#> [57] "CRAN"                            "CRAN"                           
#> [59] "GitHub repo = cjtexas/colourgen" "CRAN"
allmypackages$whereat <- sapply(allmypackages$Package, package_source)

Created on 2019-05-14 by the reprex package (v0.2.1)