Win 10,使用 Git bash。Git 版本 2.32.0.windows.1。研究了類似/相同的主題,他們沒有幫助。
我是 Git 的新用戶,正在嘗試學習如何使用它,以前從未使用過版本控制系統,也沒有任何人可以詢問或展示給我。
我遵循教程,甚至了解到目前為止發生了什么,但是推送到遠程存盤庫需要永遠并且什么都不做。到那時為止,一切都奏效了。
我正在使用的教程:帶有時間戳的 YouTube 鏈接
我成功地做到了:創建了我的第一個本地存盤庫,創建了虛擬測驗檔案(為帶有一些文本的 PCB CAD 程式隨機撰寫了一個腳本,我猜這無關緊要),學會了創建一個分支并將內容提交到本地分支。我的頭快要爆炸了,但它有效,到目前為止我理解它。但是推送到遠程倉庫會掛起而沒有給出任何提示或線索。
我做了一些研究,并在 StackOverflow 上找到了這個主題:鏈接
我在 push 命令中添加了 --verbose,所以現在看起來像這樣:
$ git push -u --verbose origin main
Pushing to https://github.com/ellectroid/test_public_repository.git
然后它永遠掛起。資訊量很大。
此外,在上面鏈接的 stackoverflow 帖子中,有人談到了協議。我試過http和https。沒有不同。
然后有人(經過 Azeez)說要確保我在 GitHub 上通過了身份驗證。好吧,我在瀏覽器中登錄了,雖然我不明白它是如何連接的,但我登錄了。然后在同一篇文章中他們寫了一些參考:
為“https://github.com/”選擇一種身份驗證方法:
- 網路瀏覽器(默認)
- 個人訪問令牌選項(默認輸入):
我完全不知道這是什么,我從來沒有被要求在 bash 中驗證任何東西,我也不知道該怎么做。本教程沒有這樣做,并且一切都開箱即用。
我是一個 100% Git 和 GitHub 菜鳥,半年前注冊了一個帳戶,但今天是我實際嘗試使用它的第一天,我立即得到了這個,但我不知道為什么以及要做什么做,所以如果您的回復詳細解釋了該怎么做,我將不勝感激。我只是希望能夠將本地存盤庫中的內容推送到 GitHub。
如果重要的話,我沒有使用任何代理或任何東西。
如果您需要我提供更多資訊,請告訴我哪些資訊以及我從哪里獲得這些資訊。正如我所說,我對 Git 一無所知,但非常想知道。
PS 我知道 master 和 main 分支名稱并考慮了它。
更新
On the next day when I tried to push, a Git GUI popped up with openSSH in window title asking me for GitHub username. I entered my username, which was for some reason all with asterisks (never seen login written with asterisks), I entered my GitHub username "ellectroid" and got "Application error" window with text "Error: error writing "stdout": broken pipe". I opened detailed error message, it says:
error writing "stdout": broken pipe
error writing "stdout": broken pipe
while executing
"puts $::answer"
(procedure "finish" line 14)
invoked from within
"finish"
invoked from within
".b.ok invoke"
("uplevel" body line 1)
invoked from within
"uplevel #0 [list $w invoke]"
(procedure "tk::ButtonUp" line 24)
invoked from within
"tk::ButtonUp .b.ok"
(command bound to event)
UPDATE 2 After extensive googling I found what person in the comments was talking about. Turns out there is a file with the name "config" without extension in the hidden folder .git in my local repo (was it difficult to explain like this? Sorry, I said I'm noob, you could word it friendlier for noobs), so here are the contents of this "config" file:
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
[remote "origin"]
url = https://github.com/ellectroid/test_public_repository.git
fetch = refs/heads/*:refs/remotes/origin/*
[remote "origin2"]
url = http://github.com/ellectroid/test_public_repository.git
fetch = refs/heads/*:refs/remotes/origin2/*
I tried origin2 to try with http instead of https. I still get error when authenticating on github in Git GUI OpenSSH window, where I enter my login with asterisks ("ellectroid") and it spews out broken pipe error like above.
UPDATE 3
Thanks to @VonC, who invited me to the chat, we figured out all I had to do is to push not from the Git Bash, but from Windows CMD. Then, when I push, it immediately prompted me to use Personal Access Token, which I already created. Also, I did it with admin rights. Later on I changed environment variable PATH to include path to bash, so I can just write "bash" in CMD and get fancy colors and stuff. Case closed.
uj5u.com熱心網友回復:
在 Windows 上,嘗試從命令列(而不是從 GUI)推送以測驗它是否有效。
確保在一個簡單的 CMD 中:
git config credential.helper確實回來了manager-core- git ls-remote https://github.com/ / 觸發一個彈出視窗,您可以在其中輸入您的 GitHub 用戶帳戶名和您的 PAT(您需要先創建的個人訪問令牌)
然后嘗試git push從本地存盤庫檔案夾中。
從討論中,這開始與:
C:\Program Files\Git\bin,所以你需要將它添加到系統PATH(它是在哪里bash.exe)- 以管理員身份打開的 CMD
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/360186.html
標籤:git github git-bash git-for-windows
上一篇:恢復Master后的Git合并
