我正在嘗試編寫git
的自定義命令。我希望它的行爲與git rebase -i
一樣,在VIM中打開一個文件,寫入+退出該文件將觸發更多代碼。如何使命令類似於「git rebase -i」
什麼,我指的是
什麼的實例在運行git rebase -i
,該文件打開:
noop
# Rebase 3ffddbe..3ffddbe onto 3ffddbe (1 command(s))
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x, exec = run command (the rest of the line) using shell
# d, drop = remove commit
#
# These lines can be re-ordered; they are executed from top to bottom.
#
# If you remove a line here THAT COMMIT WILL BE LOST.
#
# However, if you remove everything, the rebase will be aborted.
#
# Note that empty commits are commented out
通常有承諾哈希那裏,你能夠壓制或什麼的。我想要類似的地方,我可以運行我的自定義git edmund
命令,它會打開文件中的結果。
所以我的目標是:
1)git的埃德蒙
2)編輯打開的文件。我想要的內容看起來像這樣(的git log -n 3 --pretty=format:"%H %cN"
基本的結果):
3ffddbebbfb8eef48e69ca455628bd8b94f00eed Edmund
5ae79d3d7b0e8b33d0f3dcc366439e62e5703e1d Charlie
2063a5fce18972fee0bfa589ee2e2668f5a026f9 Kevin
3)解析該文件
你真正的MVP。謝謝!! – Edmund
這是否使用git配置的'core.editor'? – rubenvb
不是書面的,但顯然你可以修改調用編輯器的行,也要求'git config'提供這些信息。 – larsks