Love My Love

Git Tips

2020.07.26

# Constantly

# git remote add
git remote add origin https://e.coding.net/wedojava/hugo/zozo.git
# git remote 重新设置
git remote set-url origin https://e.coding.net/wedojava/hugo/zozo.git
git push -u origin master
git clone https://github.com/varkai/hugo-theme-zozo themes/zozo
git submodule add https://github.com/budparr/gohugo-theme-ananke.git themes/ananke
git submodule add -b master https://gitee.com/wedojava/wedojava.git public
git config --global user.email "wedojava@gmail.com"

# Roll Back

Reference:
https://github.com/includeios/document/issues/12
https://www.liaoxuefeng.com/wiki/896043488029600/897013573512192
https://ruby-china.org/topics/11637
https://codertw.com/%E7%A8%8B%E5%BC%8F%E8%AA%9E%E8%A8%80/561978/
https://www.cnblogs.com/keystone/p/10700617.html

Method 1.1

git reset --hard HEAD^        回退到上个版本
git reset --hard commit_id    退到/进到 指定commit_id
git push origin HEAD --force  把回退的某个版本提交的远程

Method 1.2

git reset --hard dbf5efdb3cd8ea5d576f2e29fe0db1951d0e3e3b

# 强制推送到远程分支, 会抹去远程库的提交信息, 不要这么干
# git push -f origin master

Method 2

# 回退到指定版本, 需要解决冲突
git revert e7c8599d29b61579ef31789309b4e691d6d3a83f

# 放弃回退(加--hard会重置已 commit和工作区的内容)
# git reset --hard origin/master

# log

可以查看所有分支的所有操作记录(包括(包括commit和reset的操作),包括已经被删除的commit记录,git log则不能察看已经删除了的commit记录

git reflog                  打印你记录你的每一次操作记录
发表评论