致命:pathspec'https:// user:pass@bitbucket.org/user/my_repo.git'与任何文件都不匹配

时间:2017-07-07 15:18:18

标签: git bitbucket

我有一个相对复杂的git语句,其内容如下:

git -C /Users/user_name/s/f/f_start/ add https://user:pass@bitbucket.org/user/my_repo.git -A && git -C /Users/user_name/s/f/f_start/ commit  https://user:pass@bitbucket.org/user/my_repo.git -m "update 20170707"

产生以下错误:

fatal: pathspec 'https://user:pass@bitbucket.org/user/my_repo.git' did not match any files

现在,如果我本地cd到那条路径& git status我明白了:

On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

    modified:   data_1.p

no changes added to commit (use "git add" and/or "git commit -a")

所以,这是一个git repo。

现在,如果我跑:

git commit data_1.p -m "update"

我明白了:

[master 377c61b] update
 1 file changed, 0 insertions(+), 0 deletions(-)

git push产生:

Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.12 KiB | 0 bytes/s, done.
Total 3 (delta 2), reused 0 (delta 0)
To https://user:pass@bitbucket.org/user/my_repo.git
   74ad924..377c61b  master -> master

然而,如果我简化我的git命令并运行:

git -C /Users/user_name/s/f/f_start/ commit  https://user:pass@bitbucket.org/user/my_repo.git -m " 20170707"

我明白了:

error: pathspec 'https://user:pass@bitbucket.org/user/my_repo.git' did not match any file(s) known to git.

有人可以帮助诊断我在这里做错了什么吗?

我提供用户名和密码,因为这是分布式代码。

1 个答案:

答案 0 :(得分:1)

您无需在每个命令中提供远程存储库URL。

git add命令只接受pathspec作为参数,因此您的命令正在尝试添加一个不存在的文件https://user:pass@bitbucket.org/user/my_repo.git

只需删除命令中的URL:

git -C /Users/user_name/s/f/f_start/ add -A
git -C /Users/user_name/s/f/f_start/ commit -m "update 20170707"

# Then simply publish
git -C /Users/user_name/s/f/f_start/ push

设置/更改远程存储库URL的唯一git命令是git remote

git remote origin --set-url https://user:pass@bitbucket.org/user/my_repo.git
git remote -v