为bitbucket repo设置同步时,获取错误为非git repo

为bitbucket repo设置同步时,获取错误为非git repo,git,bitbucket,Git,Bitbucket,尝试在本地服务器上为bitbucket repo设置同步时,收到的错误是而不是git repo。下面是我发出的命令: $ git --git-dir=~/gitRepo/my_repo.git remote add origin git@bitbucket.org:username/my_repo.git fatal: Not a git repository: '~/gitRepo/my_repo.git' 甚至我也尝试初始化回购协议(之前我没有这么做),但仍然出现了相同的错误。以下是我在阅

尝试在本地服务器上为bitbucket repo设置同步时,收到的错误是而不是git repo。下面是我发出的命令:

$ git --git-dir=~/gitRepo/my_repo.git remote add origin git@bitbucket.org:username/my_repo.git
fatal: Not a git repository: '~/gitRepo/my_repo.git'
甚至我也尝试初始化回购协议(之前我没有这么做),但仍然出现了相同的错误。以下是我在阅读了Git教程后遵循的步骤(因为我是Git新手,所以如果我问了一个非常基本的问题,我很抱歉)


是我错过的东西。基本上,我正在尝试设置Redmine与BitBucket的同步,这是所需的步骤之一。

如果在执行第一个命令时没有初始化repo,则错误消息是正常的:您需要在添加任何远程操作之前创建repo

至于您的第二条错误消息:如果您在git repo目录本身中(在
git init
之后),那么作为注释,您不需要
--git dir
参数。
但是,如果仍然要添加
--git dir
参数,则非裸回购的
--git dir
引用的路径必须以
/.git
结尾(就像您在第一个命令中所做的那样)

即使在
~/gitRepo/my_repo
中创建git repo之后:

  • ~/gitRepo/my_repo
    不是git repo
  • ~/gitRepo/my_repo/.git
试着省略
--git dir
参数,只从
my\u repo
目录运行命令。
$ git init
Initialized empty Git repository in ~/gitRepo/my_repo/.git/
$ git --git-dir=~/gitRepo/my_repo remote add origin git@bitbucket.org:username/my_repo.git
fatal: Not a git repository: '~/gitRepo/my_repo'