克隆命令
条件:首先需要魔法上网,否则国内是无法连接GitHub的。其次需要设置代理的端口,否则也会提示连接失败。
1
2
3
|
git clone https://github.com/neilsonnn/image-blaster "F:/00_Imrcao/01_MyProject/ImageBlaster"
Cloning into 'F:/00_Imrcao/01_MyProject/ImageBlaster'...
fatal: unable to access 'https://github.com/neilsonnn/image-blaster/': Failed to connect to github.com p
|
设置代理端口
1
2
|
git config --global http.proxy http://127.0.0.1:<端口>
git config --global https.proxy http://127.0.0.1:<端口>
|
清除代理端口:
1
2
|
git config --global --unset http.proxy
git config --global --unset https.proxy
|
查看代理端口:
1
2
|
git config --global --get http.proxy
git config --global --get https.proxy
|
常用git命令#
初始化与首次提交
1
2
3
|
git init # 在当前目录初始化 Git 仓库
git add . # 将所有文件添加到暂存区
git commit -m "Initial commit" # 创建首次提交
|
关联远程仓库
1
2
3
|
git remote add origin <url> # 关联远程仓库
git branch -M main # 将当前分支重命名为 main
git push -u origin main # 推送并设置上游追踪
|
日常操作
1
2
3
4
5
6
7
8
9
|
git status # 查看工作区和暂存区状态
git status -s # 短格式输出
git status -uall # 显示所有未跟踪的文件(和sourcetree上的“未暂存文件”显示的一样)
git diff # 查看未暂存的修改
git diff --staged # 查看已暂存的修改
git add <file> # 添加指定文件到暂存区
git add . # 添加所有文件(未暂存)到暂存区
git commit -m "message" # 提交暂存的修改
git log --oneline # 查看简洁提交历史
|
分支操作
1
2
3
4
5
|
git branch # 列出本地分支
git branch <name> # 创建新分支
git checkout <name> # 切换分支
git checkout -b <name> # 创建并切换到新分支
git merge <name> # 将指定分支合并到当前分支
|
远程同步
1
2
3
|
git fetch # 拉取远程更新(不合并)
git pull # 拉取并合并远程更新
git push # 推送本地提交到远程
|
撤销与回退
1
2
3
4
|
git restore <file> # 撤销工作区的修改(未暂存)
git restore --staged <file> # 取消暂存(保留修改)
git stash # 临时保存未提交的修改
git stash pop # 恢复之前 stash 的修改
|
如果需要为当前项目 (Low_Poly_Game) 执行 git init,我可以帮你操作并创建 .gitignore 文件来排除 UE 的中间文件和编译产物。