一些不常用的git特殊操作

放弃修改,强制覆盖本地代码

git fetch --all
git reset --hard origin/master
git pull

浅拷贝

git clone --depth=1 https://......

重新绑定远程仓库

git remote set-url origin https://gitee.com/***.git

回滚上一个版本

git reset --hard HEAD^

回滚以前的版本

git reflog
git reset --hard COMMIT_ID //COMMIT_ID
or 
git reset --hard HEAD@{2}

将文件加入.gitignore

先把要忽略的文件加入.gitignore

//删除本地缓存(改变成未track状态)
git rm -r --cached .
git add . 
git commit -m 'update gitignore'

清除历史记录

git checkout --orphan temp_branch
git add -A
git commit -am "commit message"
git branch -D master
git branch -m master
git push -f origin master

评论

暂无评论