Q:

How can I send the character q to GIT from batch file

I need to show the last commit of my repository from a script for what I'm using:
git log -1 --pretty=oneline

And here come the questions:

One line prints the entire commit hash, due to want to print with this format.
git log -1 --pretty=format:%h\ %s\ %an
But part of this code inside a batch file is recognized as variable because of % signs. 
In order to finish showing the log, it is necessary to send the character q, which works perfectly when typed directly to git bash, but when send from the batch file I get "'q' is not recognized as an internal or external command".

A:

Unless you are forcing the use of the pager when issuing commands such as git log, if there is no controlling terminal, the command will not use a pager which requires you to type q to quit the pager.
You can test what I am describing here by using, say:
git log -1 --pretty=oneline | cat

Note the use of cat at the end of the command above.
If git still requires you to type a q, then you have to see if you don't have any configuration file (either global--~/.gitconfig--or local--.git/config) that is forcing git to use the pager.
You can circumvent (without changing the configuration files) the behavior of git by using something like:
GIT_PAGER= git log -1 --pretty=oneline

Note the space between the equal sign and git.
Regarding the percent signs, you probably have to give more details about your environment, as I can't see the percent signs being interpreted as variables by bash itself.

