# Bug: Git-Alias is callable from outside a git repo

3 messages from 2022-08-10 to 2022-08-12. Participants: Niklas, rsbecker@nexbridge.com, Johannes Schindelin.
Thread: https://gitlist.dev/t/58286

## Niklas, 2022-08-10 17:03

Subject: Bug: Git-Alias is callable from outside a git repo
Message-ID: <20220810170319.mxd6h2p5tm6y5xx3@imap.mailbox.org>
URL: https://gitlist.dev/e/20220810170319.mxd6h2p5tm6y5xx3%40imap.mailbox.org

```
Steps to reproduce:

1. Having the following global .gitconfig

[alias]
     f = "!echo "test""

2. Calling `git f` in a folder which does not belong to a git repo

Expected Behavior: 

Seeing some message like like
`fatal: not a git repository (or any parent up to mount point /)`

Actual Behavior:

Prints "test"

Git 2.37.1 under Arch Linux

```

## rsbecker@nexbridge.com, 2022-08-10 19:14

Subject: RE: Git-Alias is callable from outside a git repo
Message-ID: <000c01d8aced$6f67f460$4e37dd20$@nexbridge.com>
URL: https://gitlist.dev/e/000c01d8aced%246f67f460%244e37dd20%24%40nexbridge.com
In-Reply-To: <20220810170319.mxd6h2p5tm6y5xx3@imap.mailbox.org>

```
On August 10, 2022 1:03 PM, Niklas wrote:
>Steps to reproduce:
>
>1. Having the following global .gitconfig
>
>[alias]
>     f = "!echo "test""
>
>2. Calling `git f` in a folder which does not belong to a git repo
>
>Expected Behavior:
>
>Seeing some message like like
>`fatal: not a git repository (or any parent up to mount point /)`
>
>Actual Behavior:
>
>Prints "test"
>
>Git 2.37.1 under Arch Linux

I do not think this is a bug. There are git commands that do not require
repositories, like git version. Git has know knowledge of what your alias is
going to do without executing it. If your alias wanted to run git version or
git hash-object, it would not need a repository to do so.
--Randall


```

## Johannes Schindelin, 2022-08-12 21:09

Subject: Re: Bug: Git-Alias is callable from outside a git repo
Message-ID: <s08qq38q-26po-r066-soo3-po7165167s31@tzk.qr>
URL: https://gitlist.dev/e/s08qq38q-26po-r066-soo3-po7165167s31%40tzk.qr
In-Reply-To: <20220810170319.mxd6h2p5tm6y5xx3@imap.mailbox.org>

```
Hi Niklas,

On Wed, 10 Aug 2022, Niklas wrote:

> Steps to reproduce:
>
> 1. Having the following global .gitconfig
>
> [alias]
>     f = "!echo "test""

That quoting is a big bogus.

>
> 2. Calling `git f` in a folder which does not belong to a git repo
>
> Expected Behavior:
> Seeing some message like like
> `fatal: not a git repository (or any parent up to mount point /)`
>
> Actual Behavior:
>
> Prints "test"

This is by design, and definitely not a bug. It even allows you to build
relatively complex aliases that work on multiple worktrees, or even no
worktree at all.

Why would a Git alias have to be bound to any specific Git repository?

Ciao,
Johannes

```
