git交付代码时防止误提交

git提交代码时防止误提交

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

哪些代码我不想提交呢?

(1)假数据;

(2)mock(stub)数据

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

方案:

步骤一:提交代码时,把不想提交的代码备份一份,然后再revert:
git交付代码时防止误提交
 

 

步骤二:执行commit
git交付代码时防止误提交
 

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

参考:

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

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