user310291
user310291

Reputation: 38180

git log specific file with pretty format

I don't understand how to fix on cmd or powershell

git log myfile.txt --pretty=format:'%Cblue%h%Creset - %s%Creset' -n 10

as I get this error

fatal: option '--pretty=format:%Cblue%h%Creset - %s%Creset' must come before non-option arguments

Update : myfile.txt is not the output file : it is the SOURCE file for which I want GIT HISTORY

Upvotes: 0

Views: 300

Answers (1)

Zak
Zak

Reputation: 7515

I believe you have your options mixed up with the log file itself... You're trying to write to a custom log file. The log file needs to be at the end and "written to" using >.

git log --pretty=format:'%Cblue%h%Creset - %s%Creset' -n 10 > myfile.txt

I generally like to call them "log" files by using the .log format .. But that's just preference.

git log --pretty=format:'%Cblue%h%Creset - %s%Creset' -n 10 > my_git_log.log

UPDATE

When sourcing history -- Should still be at the end .. IE

git log --all -- /path/to/file/myfile.txt

Upvotes: 1

Related Questions