Github使用全攻略
2025/9/9大约 2 分钟基础工具Github操作认证方案代码仓库管理
Github使用全攻略:快速安装、认证方案与仓库操作指南
快速安装
1.申请API Token:
User_xxx Token_yyy
2.下载代码仓库,执行脚本
cd /opt/apps/falcon/
git clone https://www.github.com/test/Spring3.git
cd Spring3 && sh test.sh
3.执行命令,上传数据
cd /opt/apps/falcon/Spring3/
ifconfig > if.txt
git add --all && git commit -m a && git push https://user:[email protected]/test/Spring3.git --all
########################################################
SSH-Key认证方案 注:一个pubkey不能在多个项目中使用会报错
- ssh-keygen.exe
- cat ~/.ssh/id_rsa.pub
- Add a new public key: https://github.com/settings/ssh/new
创建仓库 001
下载仓库 001
$ git clone [email protected]:test/ATM.git
$ git config --global user.email "[email protected]"
$ git config --global user.name "Your Name"
提交修改 001
1. Open Git-Bash
2. cd ~/Desktop/github/Atom
3. git add --all; git commit -m 'test it'; git push
########################################################
Token认证方案
1.申请API Token: https://github.com/settings/tokens
Token_xxx
创建仓库 002
下载仓库 002
$ git clone https://github.com/test/webapi.git
$ git config --global user.email "[email protected]"
$ git config --global user.name "admin"
提交修改 002
1. Open Git-Bash
2. cd ~/Desktop/github/webapi
3. git add --all && git commit -m a && git push https://admin:[email protected]/test/webapi.git
git 网络代理
Flow
[Working Directory] --> $git add --> [Staging Area] --> $git commit --> [Local Repository] --> $git push/pull --> [Remote Repository]
示例:通过 SOCKS5 代理访问 GitHub
git config --global http.proxy 'socks5h://127.0.0.1:1080'
curl --socks5-hostname 127.0.0.1:1080 https://api.ipify.org
Git 设置 SOCKS5 代理
git config --global http.proxy socks5://127.0.0.1:1080
git config --global https.proxy socks5://127.0.0.1:1080
git config --global http.proxy socks5://用户名:密码@代理IP:端口
git config --global https.proxy socks5://用户名:密码@代理IP:
git config --global https.proxy socks5://user123:[email protected]:1080
编辑 ~/.gitconfig 文件,添加:
[http]
proxy = socks5://用户名:密码@代理IP:端口
[https]
proxy = socks5://用户名:密码@代理IP:端口
验证与取消
git config --global --get http.proxy
git config --global --get https.proxy
git config --global --unset http.proxy
git config --global --unset https.proxy