简体   繁体   English

Git:如何避免在分支中合并/获取错误的遥控器?

[英]Git: How to avoid merging / fetching a wrong remote in a branch?

Say that I'm on my feature branch XXXX and issuing a git pull bad_remote master here is a BAD thing to do (in the way our workflow and branches are set up, of course). 说我在我的特性分支XXXX,并出具了git pull bad_remote master在这里(在我们的工作流程和分支机构设置方式,当然)做坏事

Is there a way to tell git (or via some Bash magic) to NOT EVER merge or fetch from that remote if you're not in a local branch named YYYY (the branch that is supposed to receive the bad_remote changes)? 如果您不在本地名为YYYY的分支(应该接收bad_remote更改的分支)中,是否有办法告诉git(或通过某种Bash魔术)永远不要从该远程进行合并或获取? Having it spitting to me some bad words would a nice feature :) 让我随地吐痰一些不好的话会是一个不错的功能:)

I know how to solve the problem as soon as it happens, but if that happens and I'm not immediately aware of that... well... cherry-pick is my friend :( 我知道如何尽快解决问题,但是如果发生这种情况,并且我没有立即意识到这一点...好吧... cherry-pick是我的朋友:(

Looking at hooks seems that the pre-merge is (still?) missing. 看着钩子似乎没有(仍然?)预合并。

Thank you. 谢谢。

This may not solve your problem, but to me it seems you worry about this too much. 这可能无法解决您的问题,但对我来说,您似乎对此太担心了。

You have nothing to lose when fetching. 提取时没有损失。 In fact, it is always good, because the remote branches reflect the remote repositories' commit history. 实际上,这总是好事,因为远程分支反映了远程存储库的提交历史。

If you merge with the remote branch by mistake, you can always return to the commit you were on using git reset --hard . 如果您错误地与远程分支合并,则始终可以使用git reset --hard返回到提交时的状态。 (If you have any working directory changes, git stash; git reset --hard; git stash pop; (如果您对工作目录进行了任何更改,则git stash; git reset --hard; git stash pop;

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

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