Git push reminder / helper?

Sometimes I need (in order to speed up development) in my code. It could be credentials, or maybe just a hack so that I can test a specific function. For many reasons, I never want to push this code to the main code base or even the development branch. I have been using the git -assume-unchaged 'command for some time now, but after merging, reinstalling, etc. that can get confusing and you can push what you don't need. Is there a cool clean way to achieve this? maybe some command that warns me that I have to remember to check the file before pushing or something? any ideas?

+3


source to share


2 answers


In many cases (like credentials) I would suggest thinking about ways you can avoid to put them - even temporarily - in controlled source files. (This may help you in other ways as well.) But there may be times where temporary code is the easiest workflow for you, so ...

One solution would be to use a hook pre-commit

. You could mark your temp code with a comment (something like // xxxTEMPxxx

in C-type languages, perhaps) and then reject any commit that finds your marker in diff. See Example c .git/hooks/pre-commit.sample

.



You can then save your change when you work, commit, or do anything, but if you git add

change you will be reminded that it is there and can turn it off. (If you are working with other code in the same file, you can use git add -p

to selectively commit the changes you intend to commit while keeping your temporary code intact.)

Of course, your temp changes still exist as unreproducible changes that might interfere with some operations; but in this case you can hide them. It should be better than trying to play with assume-unchanged

at least.

+4


source


If you want to view the files that you have changed, you can use git gui

. With this, you can select the modified files to click.



0


source







All Articles