ZhangZhihui's Blog  

 

ZhangZhihui@ZZHPC MINGW64 /e/WeChatProjects/MySongList
$ git init
Initialized empty Git repository in E:/WeChatProjects/MySongList/.git/

ZhangZhihui@ZZHPC MINGW64 /e/WeChatProjects/MySongList (main)
$ git add .

ZhangZhihui@ZZHPC MINGW64 /e/WeChatProjects/MySongList (main)
$ git commit -m "Initial"

ZhangZhihui@ZZHPC MINGW64 /e/WeChatProjects/MySongList (main)
$ git branch -M main

ZhangZhihui@ZZHPC MINGW64 /e/WeChatProjects/MySongList (main)
$ git remote add origin git://github.com/ZhangZhihuiAAA/MySongList.git

ZhangZhihui@ZZHPC MINGW64 /e/WeChatProjects/MySongList (main)
$ git push -u origin main
fatal: read error: Invalid argument

 

Ah! That fatal: read error: Invalid argument when trying to push usually happens due to using the git:// protocol on Windows, especially on Git Bash (MINGW64). The git:// protocol is read-only and not secure; it often causes issues for pushing. On Windows, it also sometimes triggers low-level read errors.

Here’s how you can fix it:


1. Use HTTPS or SSH instead of git://

Instead of:

git://github.com/ZhangZhihuiAAA/MySongList.git

Use HTTPS:

git remote set-url origin https://github.com/ZhangZhihuiAAA/MySongList.git

Or SSH (if you have SSH keys set up):

git remote set-url origin git@github.com:ZhangZhihuiAAA/MySongList.git

Then try pushing again:

git push -u origin main

2. Verify remote URL

Check with:

git remote -v

You should see something like:

ZhangZhihui@ZZHPC MINGW64 /e/WeChatProjects/MySongList (main)
$ git remote -v
origin  git@github.com:ZhangZhihuiAAA/MySongList.git (fetch)
origin  git@github.com:ZhangZhihuiAAA/MySongList.git (push)

3. Optional: Remove and re-add origin

If the above still fails:

git remote remove origin
git remote add origin https://github.com/ZhangZhihuiAAA/MySongList.git
git push -u origin main

💡 Tip: On Windows, git:// is rarely needed. HTTPS is simpler and more reliable for both fetch and push.

 

posted on 2025-12-16 19:10  ZhangZhihuiAAA  阅读(2)  评论(0)    收藏  举报