简体   繁体   English

.cmd批处理文件未将我的本地.git存储库推送到GitHub

[英].cmd Batch file not pushing my local .git repo to GitHub

I have this 'gittify.cmd' batch file in my working directory: 我的工作目录中有这个“ gittify.cmd”批处理文件:

git status
git add --all
git status
set /p commitComment=Enter the Commit Comment:%=%
@echo git commit -m "%commitComment%"
git status
git push origin master

The problem is that it's not pushing the changes to GitHub... But if I type in by hand, command by command, it works without problem. 问题是它没有将更改推送到GitHub ...但是,如果我手动输入命令,那么它将正常工作。

This is the last commands after "git push origin master": 这是“ git push origin master”之后的最后一条命令:

C:\www\lantosistvan.com>git push origin master
github --credentials get: github: command not found
Username for 'https://github.com': <My username>
Password for 'https://<My username>@github.com':
github --credentials store: github: command not found
Everything up-to-date

After this, I need to delete from local .git the particular file with this command: 之后,我需要使用以下命令从本地.git删除特定文件:

git reset HEAD <stucked file>

UPDATE 1: 更新1:

This is in my PATH: 这是我的路径:

C:\Users\<My username>\AppData\Local\GitHub\PortableGit_<code>\bin

I can run git in cmd and ConEmu without problem. 我可以在cmd和ConEmu中运行git,而不会出现问题。

git config --global credential.helper

not showing anything. 什么也没显示。

I not use SSH when I pushing to GitHub. 推送到GitHub时不使用SSH。 I always type in my Username and Pass. 我总是输入我的用户名和密码。

UPDATE 2: 更新2:

On my computer, GitHub and Git Bash installed in the same time. 在我的计算机上,GitHub和Git Bash同时安装。 PATH only directed to GitHub folder under AppData. PATH仅定向到AppData下的GitHub文件夹。

UPDATE 3 - SOLUTION: 更新3-解决方案:

For some reason, @echo caused the error. 由于某些原因,@ echo导致了错误。 it's just simple blocks somehow the commiting. 这只是以某种方式提交的简单块。 So before git push origin master, my working directory wasn't clean. 所以在git push origin master之前,我的工作目录不干净。 Removing @echo solves the problem: 删除@echo可解决问题:

git status
git add --all
git status
set /p commitComment=Enter the Commit Comment:%=%
git commit -m "%commitComment%"
git status
git push origin master

It looks like you have a credential helper configured for Git, and there seems to be a problem with calling it locally. 看来您已经为Git配置了凭据帮助程序 ,并且在本地调用它似乎有问题。

Can you do the following: Check which credential helper is installed by running 您可以执行以下操作:通过运行以下命令检查安装了哪个凭据帮助程序

git config --global credential.helper

This should print the credential helper executable's name and path. 这应该打印凭证帮助程序可执行文件的名称和路径。 Verify that this file is installed locally and is included in your shell's path. 验证此文件是否已本地安装并包含在外壳程序的路径中。

From the message, it looks like the github executable is not on your PATH . 从消息中,看起来github可执行文件不在您的PATH Try to fix that and then run the batch file again. 尝试解决该问题,然后再次运行该批处理文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM