diff --git a/configure.ac b/configure.ac
index 78f6c30a49cbb72a747699efa68adf1d95aa4278..0c42e1e2666294bc4f802dedf2844f641b716306 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,7 +18,7 @@
 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
 # USA.
 
-AC_INIT([GNU nano], [2.5.3-git], [nano-devel@gnu.org], [nano])
+AC_INIT([GNU nano], [2.5.3], [nano-devel@gnu.org], [nano])
 AC_CONFIG_SRCDIR([src/nano.c])
 AC_CANONICAL_HOST
 AM_INIT_AUTOMAKE
@@ -692,6 +692,16 @@ AM_CONDITIONAL(GROFF_HTML, test x$groff_html_support = xyes)
 AC_CHECK_PROG(haveit, makeinfo, yes, no)
 AM_CONDITIONAL(HAVE_MAKEINFO, test x$haveit = xyes)
 
+AC_MSG_CHECKING([whether building from git])
+if test -d .git ; then
+    AC_MSG_RESULT([yes])
+    AC_PATH_PROG([GIT], [git])
+    REVISION=`($GIT rev-parse --is-inside-work-tree >/dev/null 2>&1) && ($GIT rev-parse --short HEAD)`
+    AC_SUBST(REVISION)
+    AC_DEFINE_UNQUOTED([REVISION],"${REVISION}","Setting REVISION in config.h.")
+else
+    AC_MSG_RESULT([no])
+fi
 
 AC_CONFIG_FILES([
 Makefile
diff --git a/src/nano.c b/src/nano.c
index ec30a8ae17d94bc0b5e97b55eb4340e06ee04107..1e77fa5eaec62b83c12edfc5ec41f0975d9c01f6 100644
--- a/src/nano.c
+++ b/src/nano.c
@@ -933,7 +933,11 @@ void usage(void)
  * it was compiled with. */
 void version(void)
 {
+#ifdef REVISION
+    printf(" GNU nano from git, commit %s (after %s)\n", REVISION, VERSION);
+#else
     printf(_(" GNU nano, version %s\n"), VERSION);
+#endif
     printf(" (C) 1999..2016 Free Software Foundation, Inc.\n");
     printf(
 	_(" Email: nano@nano-editor.org	Web: http://www.nano-editor.org/"));
diff --git a/src/nano.h b/src/nano.h
index b79f3d236ef917a49a34393e0e3216ace731e318..f811f33805ceb8ab51dd628609d0f439daa95d9d 100644
--- a/src/nano.h
+++ b/src/nano.h
@@ -581,4 +581,10 @@ enum
 /* The maximum number of bytes buffered at one time. */
 #define MAX_BUF_SIZE 128
 
+#ifdef REVISION
+#define BRANDING PACKAGE_VERSION"-git  "REVISION
+#else
+#define BRANDING PACKAGE_STRING
+#endif
+
 #endif /* !NANO_H */
diff --git a/src/winio.c b/src/winio.c
index b6df8eaccabd86ed3da0e1265a5415b215650f76..28de9878e7f012a70601be8592e23dfccd7a86fb 100644
--- a/src/winio.c
+++ b/src/winio.c
@@ -1952,9 +1952,8 @@ void titlebar(const char *path)
 {
     int space = COLS;
 	/* The space we have available for display. */
-    size_t verlen = strlenpt(PACKAGE_STRING) + 1;
-	/* The length of the version message in columns, plus one for
-	 * padding. */
+    size_t verlen = strlenpt(BRANDING);
+	/* The length of the version message in columns. */
     const char *prefix;
 	/* "DIR:", "File:", or "New Buffer".  Goes before filename. */
     size_t prefixlen;
@@ -1996,8 +1995,7 @@ void titlebar(const char *path)
     if (space >= 4) {
 	/* Add a space after the version message, and account for both
 	 * it and the two spaces before it. */
-	mvwaddnstr(topwin, 0, 2, PACKAGE_STRING,
-		actual_x(PACKAGE_STRING, verlen));
+	mvwaddnstr(topwin, 0, 2, BRANDING, actual_x(BRANDING, verlen));
 	verlen += 3;
 
 	/* Account for the full length of the version message. */