常用的 Git 命令
更新端口刷新DNS
git config --global http.proxy 127.0.0.1:7890
git config --global https.proxy 127.0.0.1:7890
ipconfig/flushdns
代码仓库拉取推送
拉取仓库本地到本地推送到远程仓库
git clone https://github.com/lllyasviel/Fooocus.git
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
git remote set-url origin git@github.com:lllyasviel/Fooocus.git
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
ssh -T git@github.com
git add .
git commit -m "Test"
本地推送到远程仓库
git push origin main
远程仓库同步到本地
git pull origin main
1. 克隆远程仓库
克隆一个远程仓库到本地,命令如下:
git clone https://github.com/lllyasviel/Fooocus.git
2. 检查当前 Git 配置
查看 Git 的全局配置,如用户名和邮箱:
git config --list
3. 检查当前状态
查看当前工作目录和暂存区的状态(哪些文件已修改、未跟踪等):
git status
4. 添加文件到暂存区
将文件添加到暂存区,准备提交:
git add <file_name> # 添加指定文件
git add . # 添加所有修改的文件
5. 提交更改
提交更改并添加提交信息:
git commit -m "描述本次提交的内容"
6. 推送远程仓库
将本地更改推送到远程仓库:
git push origin branch-name
7. 远程仓库更新
拉取远程仓库的更新,并合并到当前分支:
git pull origin branch-name
8. 查看远程仓库信息
查看当前项目的远程仓库地址:
git remote -v
9. 查看提交历史
查看提交历史记录:
git log
10. 创建新分支
创建一个新分支,并切换到该分支:
git checkout -b new-branch-name
11. 切换分支
切换到已有的分支:
git checkout branch-name
12. 合并分支
将当前分支合并到目标分支:
git merge branch-name
❤️ 转载文章请注明出处,谢谢!❤️