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.