Sure you can use a config file. It's called a "header" file, and you just #include it in your sketch.
[config.h (not pushed)]
const char *password = "DOD982yp398fhgpwbn09tupf0p04";
[sketch.ino (pushed)]
#include "config.h"
// Now you can use the password variable.
Another method, which is better if you have multiple files in your sketch, is to use #define instead of variables in your header file:
[config.h]
#define WIFI_PASSWORD "348r0yp80ytwp85tpj8yjp98y97t8t"
[sketch.ino]
#include "config.h"
const char *password = WIFI_PASSWORD;