Git使用

Posted by Turingdo Studio on October 11, 2017

1.回退

廖雪峰GIT教程

  • HEAD指向的版本就是当前版本,因此,Git允许我们在版本的历史之间穿梭,使用命令git reset --hard commit_id

  • 穿梭前,用git log可以查看提交历史,以便确定要回退到哪个版本。

  • 要重返未来,用git reflog查看命令历史,以便确定要回到未来的哪个版本

2.分支命令

Git鼓励大量使用分支:

  • 查看分支:git branch

  • 创建分支:git branch <name>

  • 切换分支:git checkout <name>

  • 创建+切换分支:git checkout -b <name>

  • 合并某分支到当前分支:git merge <name>

  • 删除分支:git branch -d <name>

3.bug修复

  • 修复bug时,我们会通过创建新的bug分支进行修复,然后合并,最后删除;

  • 当手头工作没有完成时,先把工作现场git stash一下,然后去修复bug,修复后,先用git stash list查看,再git stash pop,回到工作现场。