How to do a pre-checkout with Git

岁酱吖の 提交于 2019-12-10 18:44:24

问题


I would like to move some files before doing a git checkout on a specific branch, and to execute some scripts.

There is no way to do an alias to checkout with my scripts, I really need a hook.

I saw many links and it seems the the pre-checkout hook is not yet implemented. Is there a way to do so?


回答1:


you can use git stash that grab your local changes.

Usually i do next:

git stash -u; 
git checkout <branch>; 
git stash pop

Execute them in one line with && and you will get way to move your changes across branches.

git stash -u && git checkout <branch> && git stash pop



回答2:


Use `git stash´ may be that you want.

Git Tools - Stashing



来源:https://stackoverflow.com/questions/40725328/how-to-do-a-pre-checkout-with-git

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