Git
353 字
2 分钟
--
Git
文章摘要
本文介绍Git LFS安装、代理配置及常用操作,包括连接远程仓库、提交代码、清除记录和版本回退等实用技巧。
LFS安装#
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bashapt-get install git-lfs初始化#
设置用户名和密码
git config --global user.name "xwysyy"git config --global user.email ""注意,可能存在推送或者拉取失败的情况,需要设置端口代理,这里用的是v2rayN,转发端口为1080
# 配置代理git config --global http.proxy 127.0.0.1:10808git config --global https.proxy 127.0.0.1:10808# 查看代理git config --global --get http.proxygit config --global --get https.proxy# 取消代理git config --global --unset http.proxygit config --global --unset https.proxy连接远程仓库#
git remote add origin <....git>查看是否连接
git remote -vgit pull#
# 拉取默认分支git pull# 或使用带参数 pull, 拉取指定分支git pull origin mastergit add#
将文件添加到暂存区
git add <file_name>将所有修改过的文件添加到暂存区
git add .git commit#
提交暂存区的文件到本地仓库
git commit -m commit_messagegit push#
git push # git push origin master清除cache#
git rm -r --cached .清除git仓库的所有提交记录#
- 创建新分支
git checkout --orphan newBranch- 添加所有文件(除了.gitignore中声明排除的)
git add -A- 提交跟踪过的文件(Commit the changes)
git commit -am init- 删除master分支
git branch -D master- 重命名当前分支为master
git branch -m master- 重新指定远端
git remote add origin "xxx.git"-
已经有了就是git remote set-url origin ..
-
强制提交到远程master分支
git push -f origin mastergit回退到某个版本#
git reset --hard <commit>git push -f -u origin master
最后更新于 2026-01-10
部分内容可能已过时
文章目录
© 2026 xwysyy. All Rights Reserved.
评论