首页 > 解决方案 > 将现有代码推送到 VSTS 时我做错了什么

问题描述

我已经准备好用于将 Visual Studio 解决方案推送到 VSTS 的 PowerShell 脚本。

不幸的是,这发生在几周前,现在我不记得我使用了什么命令。只有我有 Powershell ISE 的输出窗口:

(以 +++ 开头的行是我今晚分析时可能使用的命令)

+++git init
Reinitialized existing Git repository in D:/Documents/Visual Studio 2017/C++_Projects/Mira_kompilator/.git/
Removing .gitignore
Removing Code/
Removing Dokumentace/
Removing Helpful stuff/
+++
git : fatal: pathspec '*' did not match any files 
At line:6 char:1
+ git add *
+ ~~~~~~~~~
    + CategoryInfo          : NotSpecified: (fatal: pathspec...match any files:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

On branch master

+++git commit

Initial commit

nothing to commit

+++git push
git : error: src refspec refs/heads/master does not match any.
At line:8 char:1
+ git push -f
+ ~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (error: src refs... not match any.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

error: failed to push some refs to 'https://.visualstudio.com/_git/Mira_kompilator'

非常感谢!

标签: git

解决方案


看起来您的脚本删除了所有文件,然后没有添加任何文件(因为文件已经消失),因此无法提交。

确保首先手动在新的克隆存储库中尝试它(意味着没有 Powershell 脚本)以确保它正常工作。
使用 git add 。而不是 git add *.
并确保您的远程仓库 URL 正确(https://.visualstudio.com看起来很奇怪)

然后克隆你的远程仓库:

cd /path/to/local/clone
# modify some files
git add .
git commit -m "first commit"
git push

推荐阅读