git笔记

作者: WangKiven | 来源:发表于2018-05-16 14:43 被阅读9次

删除已提交的文件

git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch "dir/file.txt" ' --prune-empty --tag-name-filter cat -- --all
# 提交远程
git push origin --force --all
git push origin --force --tags

git for-each-ref --format='delete %(refname)' refs/original | git update-ref --stdin
git reflog expire --expire=now --all
git gc --prune=now
git count-objects -v

也可删除文件夹

git filter-branch --force --index-filter 'git rm -r --cached --ignore-unmatch "dir/subdir" ' --prune-empty --tag-name-filter cat -- --all

回滚结点

// 查看前三个结点信息
git log -3

// 回滚到指定的版本
git reset --hard e377f60e28c8b84158

// 强制提交(origin:远程仓库名称,master:远程仓库分支)
git push -f origin master

代理设置

  • 即使git使用的链接是https,可能使用的代理还是http的,所以最好http,https同时设置
// 查看当前代理设置

git config --global http.proxy

// 设置当前代理为 http://127.0.0.1:1080 或 socket5://127.0.0.1:1080

git config --global http.proxy 'http://127.0.0.1:1080'

git config --global https.proxy 'http://127.0.0.1:1080'

git config --global http.proxy 'socks5://127.0.0.1:1080'

git config --global https.proxy 'socks5://127.0.0.1:1080' /

// 删除 proxy git config --global --unset http.proxy

git config --global --unset https.proxy

相关文章

网友评论

      本文标题:git笔记

      本文链接:https://www.haomeiwen.com/subject/mpcgsxtx.html