无论我做什么,都无法使用 Git 推送到 Heroku

Cannot push to Heroku using Git no matter what I do

编辑:我是个白痴。我需要使用 cd 来实际告诉 Git 去存储库。我找到了解决方案。

我一直在 运行 兜圈子试图解决这个问题。我创建了一个 Discord 机器人,我正在尝试使用 Git 和 Heroku 来托管它。我已经成功地到达了使我能够真正推动它的步骤,但是它给了我一个错误。

首先,我的方法。

git add . 对我不起作用。所以我指定了一个转到我的机器人的文件目录。如果我 dogit add . 放入 Git Bash,我会收到此错误消息:

warning: could not open directory 'AppData/Local/Application Data/': Permission denied
warning: could not open directory 'AppData/Local/ElevatedDiagnostics/': Permission denied
warning: could not open directory 'AppData/Local/History/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/INetCache/Content.IE5/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/INetCache/Low/Content.IE5/': Permission denied
warning: could not open directory 'AppData/Local/Microsoft/Windows/Temporary Internet Files/': Permission denied
warning: could not open directory 'AppData/Local/Temp/iu-14D2N.tmp/': Permission denied
warning: could not open directory 'AppData/Local/Temp/WinSAT/': Permission denied
warning: could not open directory 'AppData/Local/Temporary Internet Files/': Permission denied
warning: could not open directory 'Application Data/': Permission denied
warning: could not open directory 'Cookies/': Permission denied
warning: could not open directory 'Documents/My Pictures/': Permission denied
warning: could not open directory 'Local Settings/': Permission denied
warning: could not open directory 'My Documents/': Permission denied
warning: could not open directory 'NetHood/': Permission denied
warning: could not open directory 'PrintHood/': Permission denied
warning: could not open directory 'Recent/': Permission denied
warning: could not open directory 'SendTo/': Permission denied
warning: could not open directory 'Start Menu/': Permission denied
warning: could not open directory 'Templates/': Permission denied
warning: LF will be replaced by CRLF in .bash_history.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in .gitconfig.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in .lesshst.
The file will have its original line endings in your working directory
warning: LF will be replaced by CRLF in AppData/Local/AVG/Antivirus/datascan.json.
The file will have its original line endings in your working directory
error: open("AppData/Local/Comms/UnistoreDB/USS.jtx"): Permission denied
error: unable to index file 'AppData/Local/Comms/UnistoreDB/USS.jtx'
fatal: adding files failed

我已经尝试 运行以管理员身份使用它。出现以下消息:

warning: could not open directory 'AppData/Local/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/Application Data/': Function not implemented

就是这样。 . .冻结,它无法做任何事情。我需要进入它的文件并手动删除导致它损坏的文件。

总之,git add . 不是答案。所以,就像我说的,我指定了目录。它接受了它,然后我执行了以下命令:git commit -am "test"。 . . 它奏效了。 现在,问题是当我 运行 git push heroku master:

时出现以下错误消息
Enumerating objects: 65, done.
Counting objects: 100% (65/65), done.
Delta compression using up to 4 threads
Compressing objects: 100% (46/46), done.
Writing objects: 100% (65/65), 2.84 MiB | 1.02 MiB/s, done.
Total 65 (delta 13), reused 0 (delta 0), pack-reused 0
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpack: heroku/python
remote: -----> App not compatible with buildpack: https://buildpack-registry.s3.amazonaws.com/buildpacks/heroku/python.tgz
remote:        More info: https://devcenter.heroku.com/articles/buildpacks#detection-failure
remote:
remote:  !     Push failed
remote:  !
remote:  ! ## Warning - The same version of this code has already been built: bf75a0363f71778460026f132e502c0b02c5b388
remote:  !
remote:  ! We have detected that you have triggered a build from source code with version bf75a0363f71778460026f132e502c0b02c5b388
remote:  ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote:  !
remote:  ! If you are developing on a branch and deploying via git you must run:
remote:  !
remote:  !     git push heroku <branchname>:main
remote:  !
remote:  ! This article goes into details on the behavior:
remote:  !   https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: !       Push rejected to discord-mod5.
remote:
To https://git.heroku.com/discord-mod5.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/discord-mod5.git'

(我试图在 ignorace 中多次提交,因此出现“警告:触发两次”部分。当我进行新提交时,同样的事情仍然发生)。

右边就是我遇到的路障。什么都没有用。我删除并重新安装 Git Bash。没有什么。 运行 作为管理员。没有什么。更改了构建包和 added/removed 它们。没有什么。更改了 requirements.txtProcfileruntime.txt 文件内容。没有什么。将 requirements.txt 重命名为 requirement.txt。没有什么。使用 git init 在根目录中初始化,我什至指定了通往机器人的多个目录。没有任何效果。

我又回到了起点。我做错了什么,发生了什么,解决方案是什么?

我要推送的内容(按此顺序):

您的问题是您的主目录设置为 Git 存储库,您正试图将其中的所有内容添加到您的项目中。 Windows 对它允许哪些程序访问某些目录(如文档)非常严格,因此,您尝试使用 git add . 将所有内容添加到存储库的尝试没有成功。

首先,在 Git Bash 中,键入 cd 以转到您的主目录。然后,运行mv .git .git.bak。这将使您的主目录不再是 Git 存储库,但它会保留该目录以防您在其中有任何重要内容。

然后,使用 cd 进入您的项目目录。这绝对应该是一个目录 other 而不是您的主目录。我们假设它叫做 discord-mod5。 运行 git init 初始化版本库,然后 运行 git add . 然后提交。