Benj:
I suspect that you've already found an answer by now, but I see that no one has answered this question, so I will.
If I may make an alternative suggestion to the aliases file. It looks like you're trying to solve this for git.
The best way I've found to do this in Windows is to edit the ~/.bashrc
file. On most Windows machines it would be under C:\Users\<USERNAME>\.bashrc
.
You can create a function such as:
function MergeLocDistFn {
local co_branch=$1
local merge_branch=$2
echo ">> Debug Command: git checkout ${co_branch}"
git checkout ${co_branch}
echo ">> Debug Command: git merge --ff-only --verbose origin/${merge_branch} || git rebase --preserve-merges --verbose origin/${merge_branch}"
git merge --ff-only --verbose origin/${merge_branch} || git rebase --preserve-merges --verbose origin/${merge_branch}
}
Then you can create aliases in the ~/.bashrc
file, like the following:
alias mergelocdist=MergeLocDistFn
alias mm='MergeLocDistFn master master'
The advantage to this approach is that it will allow you to get really sophisticated with the function and as I'm showing here, debug it as well with echo statements.
See the attached picture of the example output.
example output from bashrc
Note also, if you'd rather do this for a PowerShell prompt, it's even easier to modify the PowerShell profile, just let me know and I'll show you how.
Another note, you can also create a function in the .bashrc for the current branch. Here's an example function:
function current_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
}
Here's an example of using the current_branch function:
alias gpush='git push -u origin $(current_branch)'
I hope that his helps, just let me know if you need any clarifications on this.