【git】Windows使用git bash上传文件到github,解决git push失败,使用token上传github

    昨天写了个特征脸的小Demo,短小精悍,于是想放到github上。

    但网页上传总会提示 "Something went really wrong, and we can’t process that file."

    于是自学了如何使用git bash,这里记录以备不时之需。

附:git bash Windows 下载地址:Git for Windows

        安装教程随便网上找一篇就好了,不多说。

这个是自学git bush 使用本地仓库及远程仓库的全过程,强烈推荐观看!!很有用!!

How to upload files to github from Git Bash on Windows from scratch_哔哩哔哩_bilibili

这里作者使用了以下几个命令

【git】Windows使用git bash上传文件到github,解决git push失败,使用token上传github_第1张图片

 1. 建立本地仓库

git init # 在要上传文件的文件夹使用,建立本地仓库

 2. 连接远程仓库

git remote add origin  # 这里放远程仓库的链接

git remote -v #查看是否连接成功

【git】Windows使用git bash上传文件到github,解决git push失败,使用token上传github_第2张图片

 3. 向缓冲区中加入要上传的文件

git add . # 使用.表示将此文件夹下的所有文件上传到缓冲区,可用想单独上传的文件名代替

4. 写更新日志

git commit -m "YOUR COMMENTS" # 双引号中写你想要写的日志 可以使用 "First commit"

【git】Windows使用git bash上传文件到github,解决git push失败,使用token上传github_第3张图片

 5. 将缓冲区中的文件送到远程仓库中

git push origin master # 直接push即可

之后会弹窗让输入github的Username和password

【git】Windows使用git bash上传文件到github,解决git push失败,使用token上传github_第4张图片password在2021年8月后不支持使用了,这里的password要使用token代替

token的位置

1. settings

【git】Windows使用git bash上传文件到github,解决git push失败,使用token上传github_第5张图片

2.左侧的Developer settings

【git】Windows使用git bash上传文件到github,解决git push失败,使用token上传github_第6张图片

3.创建一个新token

【git】Windows使用git bash上传文件到github,解决git push失败,使用token上传github_第7张图片

【git】Windows使用git bash上传文件到github,解决git push失败,使用token上传github_第8张图片

4.得到token

【git】Windows使用git bash上传文件到github,解决git push失败,使用token上传github_第9张图片

你可能感兴趣的:(github,git,bash)