Git committing creates a file called "-"

1

It's very hard to search for on Google with the amount of documentation there is about git, but basically, when I do a "git commit", it creates a file called "-". It has nothing in it, and is owned by my user. Is there a reason this file is being created and is there anything I can do to stop it since it's a little annoying? The file is not under git control. Git acts like its not even there.

UPDATE

As I'm answering questions in the comments, I realized that this happened right after I tried to make it so that I no longer needed to use "ssh-add" every time I wanted to push to a remote. The following is in my .bash_profile.

git() {
      if ! ssh-add -l >/dev/null 2>-; then
              ssh-add ~/.ssh/remote1
              ssh-add ~/.ssh/remote2
                fi
                  /usr/bin/git "$@"
}
export -f git

If this looks incorrect, let me know.

tubaguy50035

Posted 2012-05-24T04:50:32.077

Reputation: 145

1Do you just type "git commit"? (no parameter at all?) – VonC – 2012-05-24T07:38:29.623

At first I was doing "git commit -a", stopped doing that, so yes. All I'm doing is "git commit". – tubaguy50035 – 2012-05-24T08:35:37.577

1

Could you try a git add -A (see http://stackoverflow.com/questions/572549/difference-of-git-add-a-and-git-add), followed by a git commit -m "test" and see if that file '-' is still created?

– VonC – 2012-05-24T09:24:17.223

I removed the file "-" before I began. I ran "git add -A", I then ran "git commit -m "test". Git informed me of my branch, commit number, and message. It took a very long time, I ended it with "control-c". "Ls"-ed the directory, the magical "-" file had returned. – tubaguy50035 – 2012-05-24T16:01:57.117

1Curious! Can you recreate this behavior from a new repo? – invert – 2012-05-25T11:14:44.107

Yes. Upon any commit my user makes a file called "-" is created. If I make a commit as sudo, no file is created. See my updated question for more details. – tubaguy50035 – 2012-05-26T09:23:06.070

Answers

1

See the part of your command that says 2>-? That is creating/replacing a file named -. What did you mean there? Send STDERR to the same place as STDOUT? The syntax for that is 2>&1

Adrian Pronk

Posted 2012-05-24T04:50:32.077

Reputation: 305

1Redirecting to &- closes that file descriptor in bash, e.g. 2>&- – Daniel Beck – 2012-05-26T11:48:01.807

That was a straight copy from an Ubuntu help forum post. Let me change that and see what happens. – tubaguy50035 – 2012-05-26T21:37:38.123

I changed it to "2>&1", seems to have fixed the problem! Thank you! – tubaguy50035 – 2012-05-26T21:41:37.090