how to make a git alias with arguments in windwos

masiboo

I have to use this command frequently

git difftool head head~2 -- Myefile.cpp.

It is a large command to type all the time. I would like to make an alias of this command with head~n where n is a variable. I want to type

git myfilediff n

where n is an integer number.

How can I do it in windows 10?

ElpieKay

A quick and dirty solution, to define a bash function in ~/.bashrc if you are using Ubuntu or git-bash-for-windows:

function mfd() {
    git diff HEAD HEAD~${1} -- Myfile.cpp
}

source ~/.bashrc and then mfd 2 is equivalent to git diff HEAD HEAD~2 -- Myfile.cpp.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related