相关疑难解决方法(0)

if [](方括号)中"[:太多参数"错误的含义

我找不到任何一个简单直接的资源,用于解释以下BASH shell错误的含义和修复,所以我发布了我在研究之后发现的内容.

错误:

-bash: [: too many arguments
Run Code Online (Sandbox Code Playgroud)

Google友好版: bash open square bracket colon too many arguments.

上下文:单个方括号中的if条件,带有一个简单的比较运算符,如equals,大于等,例如:

VARIABLE=$(/some/command);
if [ $VARIABLE == 0 ]; then
  # some action
fi 
Run Code Online (Sandbox Code Playgroud)

bash arguments if-statement

185
推荐指数
5
解决办法
22万
查看次数

GitHub:错误:未找到存储库.致命:远程端意外挂断(显然不同于类似的帖子)

我创建了一个目录hello_git.在这个目录中,我创建了一个文件,hello_git.py打印出一个"Hello git!" 信息.

然后我hello_git在终端中创建了当前目录,并在该目录中一个接一个地输入以下命令:

git init
git add hello_git.py
git commit -m 'first commit'
git remote add origin git@github.com:githubaccountname/hello_git.git
Run Code Online (Sandbox Code Playgroud)

当我输入命令时,git push origin master我会被问到:

Enter passphrase for key '/home/myusername/.ssh/id_rsa':
Run Code Online (Sandbox Code Playgroud)

当我输入我的密码(使用成功验证ssh -T git@github.com)时,我得到了这个:

ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
Run Code Online (Sandbox Code Playgroud)

我不知道这是否有帮助,但是:

git remote -v
Run Code Online (Sandbox Code Playgroud)

收益:

origin    git@github.com:githubaccountname/hello_git.git (fetch)
origin    git@github.com:githubaccountname/hello_git.git (push)
Run Code Online (Sandbox Code Playgroud)

我已经查看了类似帖子的答案,但似乎没有任何效果:

git github

31
推荐指数
3
解决办法
7万
查看次数

错误:找不到存储库。致命:无法从远程存储库读取。请确保您拥有正确的访问权限并且存储库存在

昨天我创建了一个 ssh 密钥并克隆了一个用于工作的存储库。进行一些更改后,我尝试推送提交:

git push
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

我已经阅读了这篇活跃的 SO 帖子。我的问题仍然存在。我不知道如何找出问题所在,因此将分享我认为相关的所有内容。

在我的笔记本电脑上,我有个人和工作存储库。我的工作工作位于嵌套在~/Documents/Projects/Zen/Projects/. 其他地方例如~/Documents/Projects/Personal/用于个人github。

我的 .gitconfig 看起来像这样:

[user]
    email = 12345+doug@users.noreply.github.com
    name = 12345doug

[includeIf "gitdir:/home/doug/Documents/Projects/Zen/"]
    path = ~/.git-zen
Run Code Online (Sandbox Code Playgroud)

/.git-zen 看起来像这样:

[user]
        email = doug@work.com
        name = doug-work
Run Code Online (Sandbox Code Playgroud)

目前我在一个仓库中:

pwd
/home/doug/Documents/Projects/Zen/Projects/analytics-psql-action
Run Code Online (Sandbox Code Playgroud)

一些提交准备好推送:

~/Documents/Projects/Zen/Projects/analytics-psql-action$ git status
On branch master
Your branch is ahead of 'origin/master' by …
Run Code Online (Sandbox Code Playgroud)

git ssh github

7
推荐指数
1
解决办法
3万
查看次数

git忽略配置core.ssh命令,但可以与GIT_SSH_COMMAND =一起正常工作

我想使用配置来设置sshCommand而不是环境变量。但不起作用这是发生了什么

?  GIT_SSH_COMMAND='ssh -i /var/www/level2.lu/www/git_id_rsa -F /dev/null' git ls-remote 
From git@github.com:syn2cat/Level2.lu.git
fcaa5a2e63499568dd916e7b18f950b311781bd0    HEAD
fcaa5a2e63499568dd916e7b18f950b311781bd0    refs/heads/master
a542061a64d3698d5da54d63456b26932fe549a2    refs/pull/1/head

?  git config core.sshcommand                                                           
ssh -i /var/www/level2.lu/www/git_id_rsa -F /dev/null
?  git ls-remote
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

并进行调试,它不使用core.sshCommand中的值

? GIT_TRACE=1 git ls-remote 
13:46:15.366401 git.c:344               trace: built-in: git 'ls-remote'
13:46:15.366564 run-command.c:334       trace: run_command: 'ssh' 'git@github.com' 'git-upload-pack '\''syn2cat/Level2.lu.git'\'''
Run Code Online (Sandbox Code Playgroud)

版本号

?  lsb_release -a
No LSB modules are available. …
Run Code Online (Sandbox Code Playgroud)

git ssh

1
推荐指数
1
解决办法
1303
查看次数

如何处理多个 ssh 密钥

我在两个 github 帐户中为不同的项目创建了两个 ssh 密钥。一个是我的帐户,另一个是公司帐户 github。我使用不同的 ssh-key 从事项目。所以每次当我打开不同的项目时我都会输入这个命令。

eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa_my_git
Run Code Online (Sandbox Code Playgroud)
eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa_company_git
Run Code Online (Sandbox Code Playgroud)

我希望通过向项目或电脑添加配置文件或使用其他方式来避免每次都输入此内容。

git ssh ssh-keys

1
推荐指数
1
解决办法
5056
查看次数

标签 统计

git ×4

ssh ×3

github ×2

arguments ×1

bash ×1

if-statement ×1

ssh-keys ×1