MSYS2
pacman -Syu /d/github/env 15:32:49❯ where git/d/Git/cmd/git/usr/bin/git/usr/bin/git/d/Git/bin/git /d/github/env 15:32:54❯ whereis gitgit: /usr/bin/git.exe /usr/share/git /d/Git/cmd/git.exe /d/Git/bin/git.exe /usr/share/man/man1/git.1.gz /d/github/env 15:33:03❯ git -vgit version 2.45.0.windows.1 /d/github/env 15:33:13❯ /usr/bin/git -vgit version 2.46.0 /d/github/env 15:33:20❯git config list# git for MSYS2init.defaultbranch=mainuser.name=aauser.email=Nahida-aa@outlook.comhttp.sslverify=false# git for Windowsdiff.astextplain.textconv=astextplainfilter.lfs.clean=git-lfs clean -- %ffilter.lfs.smudge=git-lfs smudge -- %ffilter.lfs.process=git-lfs filter-processfilter.lfs.required=truehttp.sslbackend=opensslhttp.sslcainfo=D:/Git/mingw64/etc/ssl/certs/ca-bundle.crtcore.autocrlf=truecore.fscache=truecore.symlinks=falsepull.rebase=falsecredential.helper=managercredential.https://dev.azure.com.usehttppath=trueinit.defaultbranch=maininit.defaultbranch=mainuser.name=aauser.email=Nahida-aa@outlook.comhttp.sslverify=falsegithub
Section titled “github”empty github repo
Section titled “empty github repo”local repo push to empty github repo
git remote add origin git@github.com:Nahida/env.gitgit branch -M maingit push -u origin mainmodify github repo, and modify local repo, then push local repo to github repo
git pull origin main# 解决任何可能的冲突并添加解决后的文件# git add <冲突文件>
# 提交解决冲突后的更改(如果有冲突)# git commit -m "解决冲突"
# 推送本地更改到远程仓库git push origin mainno empty github repo
Section titled “no empty github repo”ssh -V# windows sc:Service Control query: 查询服务的状态sc query ssh-agent# windows net:管理本地计算机的用户帐户、组和共享资源# # start: net 的子命令,启动服务,服务名为 ssh-agentnet start ssh-agent# if MSYS2eval "$(ssh-agent -s)"# 停止服务net stop ssh-agent# 测试SSH连接ssh -T git@github.com# 应该看到以下输出# Hi <username>! You've successfully authenticated, but GitHub does not provide shell access.# 如果看到以下输出,表示SSH连接失败# ssh: connect to host github.com port 22: Connection timed outVScode: code -> github repo
Section titled “VScode: code -> github repo”默认使用的是https协议
git remote -v# outputorigin https://github.com/<your_username>/<repository>.git (fetch)origin https://github.com/<your_username>/<repository>.git (push)更改为SSH协议
git remote set-url origin git@github.com:<your_username>/<repository>.git# 更改 协议后 需要重新设置 upstreamgit push --set-upstream origin main