Git push reminder/helper?

南笙酒味 提交于 2019-12-01 19:23:21

In many cases (like credentials) I would suggest thinking about ways in which you can avoid having to put those - even temporarily - into source-controlled files. (This might end up helping you in other ways as well.) But there may just be cases where temporary code is the most straightforward workflow for you, so ...

One solution would be to use a pre-commit hook. You could mark your temporary code with a comment (something like // xxxTEMPxxx in C-like languages maybe) and then reject any commit that finds your marker in the diff. See the example in .git/hooks/pre-commit.sample.

You can then keep your change in place as you work, committing or doing whatever, but if you git add the change then you'll be reminded that it's there and can unstage it. (If you're working on other code in the same file, you can use git add -p to selectively stage the changes you intend to commit while keeping your temp code out.)

Of course your temp changes still exist as untracked changes, which can get in the way of some operations; but in that case you can stash them. It's got to be better than trying to play with assume-unchanged at least.

If you want see the files that you have modified you can use git gui. With this you can choose the modified files to push.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!