一些不经常使用的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

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

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

清除历史记录

git checkout --orphan temp_branch
git add -A
git commit -am "commit message"
// Delete
git branch -D master
// Rename
git branch -m master
git push -f origin master
相关文章
相关标签/搜索