Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
1  
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
1  
Could you try a git add -A (see stackoverflow.com/questions/572549/…), 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
1  
Curious! Can you recreate this behavior from a new repo? –  invert May 25 '12 at 11:14
show 1 more comment

1 Answer

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
1  
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.