function gm
    if not test -d .git
        echo "Not a git repository"
        return 0
    end

    if count $argv >/dev/null
        git merge $argv
    else
        set -l remote (git symbolic-ref refs/remotes/origin/HEAD | awk -F'/' '{print $4}')
        git merge origin/$remote
    end
end
