我有一个相对复杂的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 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.有人能帮我诊断一下我到底做错了什么吗?
我提供用户名和密码,因为这是分布式代码。
发布于 2017-07-07 15:41:14
您不需要在每个命令中提供远程存储库URL。
git add命令只接受路径规范作为参数,因此您的命令试图添加一个不存在的文件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 -vhttps://stackoverflow.com/questions/44974351
复制相似问题