# "git add" and absolute paths

4 messages from 2008-01-28 to 2008-01-28. Participants: Wincent Colaiuta, Johannes Schindelin, Jakub Narebski, Jeff King.
Thread: https://gitlist.dev/t/11770

## Wincent Colaiuta, 2008-01-28 12:32

Subject: "git add" and absolute paths
Message-ID: <916BAC14-A5E4-4666-A29E-2CDF114DCD87@wincent.com>
URL: https://gitlist.dev/e/916BAC14-A5E4-4666-A29E-2CDF114DCD87%40wincent.com

```
I was somewhat surprised the other day to see that you can't pass  
absolute paths to "git add":

$ cd /tmp
$ mkdir foo
$ cd foo
$ git init
Initialized empty Git repository in .git/cuzco:foo
$ echo "content" > file
$ git add /tmp/foo/file
fatal: unable to add /tmp/foo/file to index
$ git add file

I understand that you can't add arbitrary paths outside of your  
worktree, but if the absolute path specifies something _inside_ your  
worktree then it seems that this is either a bug or a "usability  
shortcoming" if you prefer to avoid the term "bug".

I also understand that providing a relative path is by far the most  
common operation, but there are real use cases where it's easier to  
pass an absolute path. For example: you're working at the console  
inside the work tree but you also have a GUI file browser open  
alongside. Sometimes it is simpler to drag-and-drop the file from the  
GUI to the console window (thus inserting the absolute path to the  
file) rather than typing out the relative path, even with  
autocompletion.

Out of curiosity I went back and looked at the last version of Git  
before "add" became a built-in (1.3.3). It also barfs for absolute  
paths:

$ git add file
Ignoring path /tmp/foo/file

So I suspect it's always been this way. Do people agree that this  
issue is worth addressing?

Cheers,
Wincent

```

## Johannes Schindelin, 2008-01-28 12:43

Subject: Re: "git add" and absolute paths
Message-ID: <alpine.LSU.1.00.0801281241550.23907@racer.site>
URL: https://gitlist.dev/e/alpine.LSU.1.00.0801281241550.23907%40racer.site
In-Reply-To: <916BAC14-A5E4-4666-A29E-2CDF114DCD87@wincent.com>

```
Hi,

On Mon, 28 Jan 2008, Wincent Colaiuta wrote:

> I was somewhat surprised the other day to see that you can't pass 
> absolute paths to "git add":

I think this is in the same ballpark as the wish to normalise paths passed 
to git add.  Not something for 1.5.4.

Personally, I have to admit that this was never an itch of mine, so I'll 
probably not "fix" it.

Ciao,
Dscho

```

## Jakub Narebski, 2008-01-28 13:08

Subject: Re: "git add" and absolute paths
Message-ID: <m33asi9jxp.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m33asi9jxp.fsf%40localhost.localdomain
In-Reply-To: <916BAC14-A5E4-4666-A29E-2CDF114DCD87@wincent.com>

```
Wincent Colaiuta <win@wincent.com> writes:

> I was somewhat surprised the other day to see that you can't pass
> absolute paths to "git add":
>
[cut] 
> 
> I understand that you can't add arbitrary paths outside of your
> worktree, but if the absolute path specifies something _inside_ your
> worktree then it seems that this is either a bug or a "usability
> shortcoming" if you prefer to avoid the term "bug".

If I remember correctly this issue was discussed on git mailing list,
and I guess there were even some patches implementing that, but I
don't know what happened iwth them: freeze persiod, troubles with
Cygwin (MS Windows), or what...

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```

## Jeff King, 2008-01-28 18:32

Subject: Re: "git add" and absolute paths
Message-ID: <20080128183223.GA31140@coredump.intra.peff.net>
URL: https://gitlist.dev/e/20080128183223.GA31140%40coredump.intra.peff.net
In-Reply-To: <m33asi9jxp.fsf@localhost.localdomain>

```
On Mon, Jan 28, 2008 at 05:08:44AM -0800, Jakub Narebski wrote:

> > I understand that you can't add arbitrary paths outside of your
> > worktree, but if the absolute path specifies something _inside_ your
> > worktree then it seems that this is either a bug or a "usability
> > shortcoming" if you prefer to avoid the term "bug".
> 
> If I remember correctly this issue was discussed on git mailing list,
> and I guess there were even some patches implementing that, but I
> don't know what happened iwth them: freeze persiod, troubles with
> Cygwin (MS Windows), or what...

I think the thread just trailed off, and no replacement patch got
submitted. See this thread:

  http://mid.gmane.org/200712032153.31322.robin.rosenberg.lists@dewire.com

-Peff

```
