美文网首页
Undoing Changes

Undoing Changes

作者: orcl_zhang | 来源:发表于2015-07-18 11:33 被阅读27次

在论坛里看到这样一个帖子:https://ruby-china.org/topics/26320
刚好几周前在公司做了一次关于git使用的分享。所以想拿出来分享下这个内容。

关于Undoing Changes

checkout

checkout有3个作用分别是:

  1. checkout files
    git checkout master切换分支
  2. checkout commit
    git checkout <commit> <file>可以checkout某个commit下的文件并放入暂存区
  3. checkout branch
    git checkout <commit>可以checkout某个commit,然后可以将当前置于某个游离的commit

整体来讲checkout可以提供一个功能review commit,并且是无害的。但是使用git checkout HEAD file,(可以省略HEAD)可以清空当前工作区的内容。

revert

通过revert commit来回滚某个历史commit,所以是安全的。

reset

reset file,可以讲暂存区的移除到工作区。
reset commit,撤销local的某个commit,有3种模式
如果只是清除或者修改某个私有分支的未提交commit,直接reset即可。
如果已经提交到remote,需要强制push。但是因为会修改历史commit记录,所以对其他人会有影响,所以不建议在公共分支上做此操作!
如果需要回滚某个公有分支的commit,可以切出私有分支revert某个commit,然后提交pr。

clean

清除Unstaging a File

参考这里:
https://www.atlassian.com/git/tutorials/undoing-changes
https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting

另外还有两篇:
https://www.atlassian.com/git/tutorials/rewriting-history
https://www.atlassian.com/git/tutorials/merging-vs-rebasing
主要介绍merge和rebase。一般用rebase -i来整理私有分支上的commit。
在私有分支上rebase其他分支来引入其他分支的commit,并且merge以后可以很好的保证一个线性的commit历史纪录。
但是永远不要在公有分支上rebase操作,因为会修改历史commit的历史纪录

git的workflow
https://www.atlassian.com/git/tutorials/syncing
thoughtbot的:
https://github.com/thoughtbot/guides/blob/master/protocol/git/README.md

另外推荐一个工具:
https://github.com/aanand/git-up

相关文章

  • Undoing Changes

    在论坛里看到这样一个帖子:https://ruby-china.org/topics/26320。刚好几周前在公司...

  • 《Kaplan GMAT 800》 语法部分笔记

    综述信息 Unnecessary changes are incorrect changes when it co...

  • 仁爱版 九年级上册英语周报作文14篇

    一:Great changes in my hometown These years, great changes...

  • Changes

    我想,我是时候做出一些改变了,不需要多大,不需要多让人惊讶,只是让自己遇见更美好的自己,坚持晚上刷牙第一天,坚持早...

  • Changes

    世界在以肉眼可见的速度变化。 10年前没有android、也没有iOS,诺基亚还在巅峰。为了给朋友弄到一台手机,我...

  • Changes

    This is an era of changing. There are millions of new thi...

  • Changes

    我可能再也不会 置生死于度外 去深爱一个女孩 登泰山之巅 潜鱼翔之海 在一个又一个的深夜 仰望星空的双眼 静候着 ...

  • Changes

    Life need some changes, then, fighting.

  • 传奇Amos

    看完The Undoing Project之后,我又想重看Danny Kahneman的《快与慢》,翻开书就看到他...

  • 这篇文章,很贵

    1 前一段,我读了迈克尔·刘易斯的新书——《思维的发现》,英文名是 “The Undoing Project - ...

网友评论

      本文标题:Undoing Changes

      本文链接:https://www.haomeiwen.com/subject/ylrpqttx.html