简体   繁体   English

Git pull --rebase推送时

[英]Git pull --rebase when push

I'd like to know if it would be possible with git to auto pull --rebase when doing git push ? 我想知道是否可以使用git在执行git push时自动pull --rebase

I mean if git push is rejected, automatically do a git pull --rebase and then git push again so I don't need to do that manually each time someone push before me. 我的意思是如果git push被拒绝,自动执行git pull --rebase ,然后再次git push ,这样每次有人在我面前git push时我都不需要手动执行。

Thanks for your answers. 谢谢你的回答。

You might want to do 你可能想做

git pull --rebase && git push

Maybe you want to create an alias for this 也许你想为此创建一个别名

git config --global alias.rbpush '! git pull --rebase && git push'

and then invoke it using: 然后使用以下命令调用它:

git rbpush

But keep in mind that the rebase might cause conflits that you have to solve. 但请记住,rebase可能会导致您必须解决的问题。 And while you are solving the conflicts another developer might push in the meanwhile. 当你解决冲突时,另一位开发人员可能会同时推动这些冲突。

[EDIT] Remove "_" in alias's name because git doesn't parse them. [编辑]删除别名中的“_”,因为git不会解析它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM