本文介绍了如何使用Git Bash推送到GitHub?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每当我需要将新的本地提交推送到GitHub时,我都使用Windows GitHub桌面应用程序。我打开它并点击同步按钮。我希望能够通过Git Bash命令行来完成。我想我要使用的命令是:

git push origin master



但是当我这样做时,我得到某种无效的用户名错误。我试过这个:



但当我这样做和 git push origin master 我得到另一个错误说 [email protected]:user / repo.git 是一个无效的回购。



在那里我改变了我的起源回到 https://github.com/user/repo.git (我认为这就是之前的设置)。但是因为我这样做,我的本地回购现在不是指向正确的远程(我可以告诉,因为 git status 没有列出1不同步提交,也没有GitHub桌面应用程序)。
$ b

这只是在我的一个测试仓库中。



我必须这么做才能使用Git Bash命令行来推送到GitHub?

解决方案

通常我在这种情况下所做的只是重头开始。这可能不是
的最佳方式,但它是有效的。


  1. 备份您的提交,例如备份最近4次未提交
    的提交

      git format-patch -4 


  2. 重新克隆回购

      git clone https://github.com/svnpenn/a 


  3. 应用您的提交。请注意,由于您说过Windows,因此您可能需要在此添加
    - keep-cr

      git am ../0001-type-magick-dev-null-exit.patch 


  4. 尝试推送再次



Whenever I need to push my new local commits to GitHub I use the Windows GitHub desktop application. I open it up and click the sync button. I want to be able to do it from the Git Bash command line. I think the command I want to use is:

git push origin master

but when I do that I get some sort of invalid username error. I tried this:

https://stackoverflow.com/a/20871910/280319

but when I do that and git push origin masterI get another error saying [email protected]:user/repo.git is an invalid repo.

Now I'm at the point where I changed my origin back to https://github.com/user/repo.git(I think that's what it was set to before). But since I did that my local repo is now not "pointing" to the correct remote(I can tell because git status doesn't list 1 out of sync commit and neither does the GitHub desktop app).

This is all just on a test repo of mine.

So what do I have to do so that I can push to GitHub using the Git Bash command line?

解决方案

Usually what I do in this situation is just "start over". It is probably not theoptimal way to do this, but it works.

  1. Back up your commits, for example to back up the last 4 commits that have notbeen pushed

    git format-patch -4
    

  2. Re clone the repo

    git clone https://github.com/svnpenn/a
    

  3. Apply your commits. Note since you said Windows, you might need to add--keep-cr here

    git am ../0001-type-magick-dev-null-exit.patch
    

  4. try pushing again

这篇关于如何使用Git Bash推送到GitHub?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 14:20