git提交代码时防止误提交

阅读更多

我已经多次git提交代码时提交了不该提交的.

哪些代码我不想提交呢?

(1)假数据;

(2)mock(stub)数据

可是,git commit时,容易提交上去,特别是使用sourceTree时.如何避免呢?

方案:

步骤一:提交代码时,把不想提交的代码备份一份,然后再revert:
git提交代码时防止误提交_第1张图片
 

 

步骤二:执行commit
git提交代码时防止误提交_第2张图片
 

步骤三:把刚才备份的还原

参考:

对git分支如何应对紧急上线:http://hw1287789687.iteye.com/blog/2270314

Git 切换分支和merge分支 :http://hw1287789687.iteye.com/blog/2225077

  • git提交代码时防止误提交_第3张图片
  • 大小: 103.6 KB
  • git提交代码时防止误提交_第4张图片
  • 大小: 105.9 KB
  • 查看图片附件

你可能感兴趣的:(git,commit,sourceTree)