6

Git 回退版本查看切换分支和tag

 1 year ago
source link: https://blog.51cto.com/u_14068620/5705680
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Git 回退版本

查看所有的历史版本,获取你git的某个历史版本的id

git log

恢复到历史版本

git reset --hard fae6966548e3ae76cfa7f38a461c438cf75ba965

把修改推到远程服务器

git push -f -u origin master

git reset (–mixed) HEAD~1

回退一个版本,且会将暂存区的内容和本地已提交的内容全部恢复到未暂存的状态,不影响原来本地文件(未提交的也
不受影响)

git reset –soft HEAD~1

回退一个版本,不清空暂存区,将已提交的内容恢复到暂存区,不影响原来本地的文件(未提交的也不受影响)

git reset –hard HEAD~1

回退一个版本,清空暂存区,将已提交的内容的版本恢复到本地,本地的文件也将被恢复的版本替换

Git 查看切换分支和tag

查看所有分支

git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/nnvm
  remotes/origin/piiswrong-patch-1
  remotes/origin/v0.9rc1

查看本地分支

git branch
git checkout -b v0.9rc1 origin/v0.9rc1

查看tag

git tag

切换tag

git checkout vuex-state_getter

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK