为什么 git 挂起 - 必须在命令后按 Enter 两次?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12700047/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:43:02  来源:igfitidea点击:

Why is git hanging - have to press enter twice after commands?

gitgithubterminal

提问by temporary_user_name

Edit: Summary: Every command entered in Git produces a hanging cursor which then says "bad input" if anything is typed before enter is pressed. No commands produce any results. I tried a fresh install with no results.

编辑:摘要:在 Git 中输入的每个命令都会产生一个悬垂的光标,如果在按下 Enter 之前输入任何内容,则会显示“错误输入”。没有命令产生任何结果。我尝试了全新安装但没有结果。

I am completelynew to Git. No idea what I'm doing whatsoever. (I'm on a Mac)

我对 Git完全陌生。不知道我在做什么。(我在 Mac 上)

I was following the basic instructions on the site:

我按照网站上的基本说明进行操作:

touch README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin [email protected]:aerovistae/MetPetDB-Mobile.git
git push -u origin master

But as soon as I type in "git init", the terminal hangs. I press enter, nothing happens, the prompt doesn't start a new line...it just starts a blank line with no blinking cursor. I press enter a second time, the prompt returns, having skipped a line in the terminal, and now waiting for my next command.

但是只要我输入“git init”,终端就会挂起。我按回车键,什么也没发生,提示没有开始新行......它只是开始一个没有闪烁光标的空行。我再次按 Enter,提示返回,在终端中跳过一行,现在等待我的下一个命令。

I don't really understand what's going on here, and I'm not sure if something's wrong or not.

我真的不明白这里发生了什么,我不确定是否有问题。

EDIT:

编辑:

Git was installed from the main downloads page.

Git 是从主下载页面安装的。

http://git-scm.com/downloads

http://git-scm.com/downloads

After I hit enter on git initI get the blinking cursor on a blank new line, and after a moment I hesitantly typed in Testingand hit enter again. It then spat out, on the next line, bad input: Testingand showed me a new prompt.

按回车后,git init我在一个空白的新行上看到闪烁的光标,过了一会儿,我犹豫地输入Testing并再次按回车。然后它在下一行吐出,bad input: Testing并向我显示了一个新提示。

I tried reinstalling, but to no avail. I try other git commands, like git config --global user.name "Meeeee"But it doesn't matter. They all produce the same hanging.

我尝试重新安装,但无济于事。我尝试了其他 git 命令,例如git config --global user.name "Meeeee"但没关系。它们都产生相同的悬挂。

采纳答案by VonC

Considering you are on OS X, and after Keith Thompson's comment, it is possible

考虑到您使用的是 OS X,并且在Keith Thompson评论之后,有可能

you've aliased git to something else (probably alias git="git credential-osxkeychain"), and you should look in ~.profileto see if you can remove the alias.

您已将 git 别名为其他内容(可能alias git="git credential-osxkeychain"),您应该~.profile查看是否可以删除别名。

  • or you have several git installed:
  • 或者你安装了几个 git:

It looks like you installed the git-credential-osxkeychainwrapper in the wrong place (did you cpto /usr/bin/gitinstead of /usr/local/git/bin?)
To fix, you'll want to just delete /usr/bin/git; assuming git is still installed in /usr/local/binit should take over.

It's actually installed to /usr/local/git/binso I just added that to my PATH.

看起来您将git-credential-osxkeychain包装器安装在错误的位置(您cp/usr/bin/git不是安装了/usr/local/git/bin?)
要修复,您只需删除/usr/bin/git; 假设 git 仍然安装在/usr/local/bin它应该接管。

它实际上已安装到,/usr/local/git/bin所以我只是将其添加到我的PATH.

回答by René H?hle

Hmm perhaps you are in a directory which is not writable?

嗯,也许你在一个不可写的目录中?

Normally you can create a directory.

通常您可以创建一个目录。

mkdir test
cd test
git init

then you init an empty GIT repo in the test folder and you should see a folder named ".git"which is hidden. Perhaps you can try to build a bare repository.

然后你在 test 文件夹中初始化一个空的 GIT 仓库,你应该看到一个名为“.git”的文件夹,它是隐藏的。也许您可以尝试构建一个裸存储库。

git --bare init

But your problem sounds a bit strange. Du you run your command with all rights?

但是你的问题听起来有点奇怪。杜你运行你的命令的所有权利?