首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >致命:路径规范'https://user:pass@bitbucket.org/user/my_repo.git‘不匹配任何文件

致命:路径规范'https://user:pass@bitbucket.org/user/my_repo.git‘不匹配任何文件
EN

Stack Overflow用户
提问于 2017-07-07 15:18:17
回答 1查看 482关注 0票数 0

我有一个相对复杂的git声明,内容如下:

代码语言:javascript
复制
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"

这将产生以下错误:

代码语言:javascript
复制
fatal: pathspec 'https://user:pass@bitbucket.org/user/my_repo.git' did not match any files

现在,如果我在本地cd到这条路径& git status,我得到:

代码语言:javascript
复制
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")

所以,这是一个吉特回购。

现在,如果我跑:

代码语言:javascript
复制
git commit data_1.p -m "update"

我得到:

代码语言:javascript
复制
[master 377c61b] update
 1 file changed, 0 insertions(+), 0 deletions(-)

git push产量:

代码语言:javascript
复制
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命令并运行:

代码语言:javascript
复制
git -C /Users/user_name/s/f/f_start/ commit  https://user:pass@bitbucket.org/user/my_repo.git -m " 20170707"

我得到:

代码语言:javascript
复制
error: pathspec 'https://user:pass@bitbucket.org/user/my_repo.git' did not match any file(s) known to git.

有人能帮我诊断一下我到底做错了什么吗?

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-07-07 15:41:14

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

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

只需从命令中删除URL:

代码语言:javascript
复制
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

代码语言:javascript
复制
git remote origin --set-url https://user:pass@bitbucket.org/user/my_repo.git
git remote -v
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44974351

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档