Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.


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
                  /usr/bin/git "$@"
export -f git

If this looks incorrect, let me know.

share|improve this question
Do you just type "git commit"? (no parameter at all?) – VonC May 24 '12 at 7:38
At first I was doing "git commit -a", stopped doing that, so yes. All I'm doing is "git commit". – tubaguy50035 May 24 '12 at 8:35
Could you try a git add -A (see…), followed by a git commit -m "test" and see if that file '-' is still created? – VonC May 24 '12 at 9:24
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 May 24 '12 at 16:01
Curious! Can you recreate this behavior from a new repo? – invert May 25 '12 at 11:14
up vote 1 down vote accepted

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

share|improve this answer
Redirecting to &- closes that file descriptor in bash, e.g. 2>&- – Daniel Beck May 26 '12 at 11:48
That was a straight copy from an Ubuntu help forum post. Let me change that and see what happens. – tubaguy50035 May 26 '12 at 21:37
I changed it to "2>&1", seems to have fixed the problem! Thank you! – tubaguy50035 May 26 '12 at 21:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .