简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM