I do have a command that works for showing the Git history of a file:
$ git show --oneline -s $(git rev-list HEAD -- 32-factures-creation.R)
0df507b9 Simplify SQL expression in 32-factures-creation.R
16f94a10 Update format of prsAnneeMois
f9a6cafb Update "Facturation à l'employeur"
74cb7d3e Add ISNULL conditions
29d4886c Add new key prsNbrJTad, and modify Excel sheet, screens and scripts
da3c94a1 Merge branch 'bugfix/87-fraction-horaire-sur-facture' into release/20.09
...
I'd like to make an alias out of it.
But if I'm using my alias:
file-history-f = "!f() { git show --oneline -s $(git rev-list HEAD -- $1); }; f"
then I just have one line outputted:
$ g file-history-f 32-factures-creation.R
f2e32231 (HEAD -> stgid-en-lecture-seule, origin/stgid-en-lecture-seule) Add stgIDReadOnly_vk
I don't understand what I'm doing wrong... The contents between the brackets is exactly what does work, when executed from the command line, with the file name being replaced by $1
...
Any idea?
BTW, my other alias:
file-history-sh = !sh -c 'git show --oneline -s $(git rev-list HEAD -- $1)'
It does output everything , like a non-filtered log output:
$ g file-history-sh 32-factures-creation.R
f2e32231 (HEAD -> stgid-en-lecture-seule, origin/stgid-en-lecture-seule) Add stgIDReadOnly_vk
e89bc4b1 (origin/master, master) Revert "Rebuild wars"
907e500a Rebuild wars
b18b8eb6 Index amounts in DocuContratCFI
d5590007 Merge branch 'master' of https://bitbucket.org/.../...
6ccde740 Merge branch 'master' of https://bitbucket.org/.../...
You need to change the alias to this:
file-history-f = "!f() { git show --oneline -s $(git rev-list HEAD -- $0); }; f"
Note the $0
instead of $1
. That's because when you use the !
syntax in a Git alias, it gets invoked with sh -c
, and with sh -c
, the first argument is $0
, not $1
. This is a quirk of POSIX shell, and it applies here as well.
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.