首页 \ 问答 \ git:切换分支,忽略任何更改而不提交(git: Switch branch and ignore any changes without committing)

git:切换分支,忽略任何更改而不提交(git: Switch branch and ignore any changes without committing)

我正在一个git分支工作,准备提交我的更改,所以我做了一个有用的提交消息的提交。 然后我不理会地对不值得保留的代码进行了微小的更改。 我现在想改变分支,但是git给了我,

错误:您对“X”有本地更改; 不能切换分支。

我以为我可以改变分支而不提交。 如果是这样,我该怎么设置呢? 如果没有,我如何摆脱这个问题? 我想忽略轻微的变化,而不必提交,只是改变分支。


I was working on a git branch and was ready to commit my changes, so I made a commit with a useful commit message. I then absentmindedly made minor changes to the code that are not worth keeping. I now want to change branches, but git gives me,

error: You have local changes to "X"; cannot switch branches.

I thought that I could change branches without committing. If so, how can I set this up? If not, how do I get out of this problem? I want to ignore the minor changes without committing and just change branches.


原文:https://stackoverflow.com/questions/1304626
更新时间:2023-12-02 12:12

最满意答案

以下是一个演示示例: http : //bl.ocks.org/tristen/0c0ed34e210a04e89984

与像Leaftlet这样的映射库不同,Mapbox GL JS没有“底图”与“其他图层”的概念。 所有图层都是同一实体的一部分:样式。 所以你需要保持一些数据层的状态,并在每次更改时调用它的source / addLayer。


Here's an example demonstrating that: http://bl.ocks.org/tristen/0c0ed34e210a04e89984

Unlike a mapping library like Leaftlet, Mapbox GL JS doesn't have a concept of "basemap" vs "other layers." All layers are part of the same entity: the style. So you need to keep some state of the data layer around and call its source/addLayer on each change.

相关问答

更多
  • 以下是一个演示示例: http : //bl.ocks.org/tristen/0c0ed34e210a04e89984 与像Leaftlet这样的映射库不同,Mapbox GL JS没有“底图”与“其他图层”的概念。 所有图层都是同一实体的一部分:样式。 所以你需要保持一些数据层的状态,并在每次更改时调用它的source / addLayer。 Here's an example demonstrating that: http://bl.ocks.org/tristen/0c0ed34e210a04e8 ...
  • 考虑到您使用的是jspm,您可能还想尝试通过GitHub回购来引用它,而不是通过npm: $ jspm install github:mapbox/mapbox-gl-js 它适用于MapboxGL的jspm v16.x和v0.21.0 。 Considering you are using jspm, you might also want to try and reference it through the GitHub repo rather than through npm: $ jspm in ...
  • 这确实是一张非常好的地图,他使用Mapbox Studio将犯罪和学校数据上传为图层来源创建。 通过遵循“ 设计地图 ”指南,您可以了解有关创建自己的地图样式的更多信息。 创建地图后,您需要通过执行以下操作获取样式ID: 接着... 现在您还提到在Android或iOS应用程序中使用这些地图,这类似于使用api(您在上面给出的链接)。 按照此示例关于在Android应用中包含Mapbox studio样式。 该示例将样式URL放在XML中,如下所示:
  • 您的问题中的两个链接(“ GEOjsonsource ”和“ DataSource ”)都描述了相同的域对象GeoJSONSource 。 第一个链接是Mapbox GL样式规范,它解释了如何在样式中声明GeoJSON源。 样式是一个JSON文件,用于描述地图的外观。 第二个链接是Mapbox GL JS API文档,它解释了如何在Mapbox GL JS中使用GeoJSONSource类。 样式中的声明用于创建GeoJSONSource的实例。 您还可以直接创建GeoJSONSource的实例。 您可能会 ...
  • 弄清楚了。 let popup = new mapboxgl.Popup() .setLngLat() .setHTML( '
    lorem ipsum blah blah
    ' ) .addTo(map); Figured it out. let popup = new mapboxgl.Popup() .setLngLat() .setHTML( '
    lorem ipsum blah blah
  • 目前还不清楚你遇到了什么问题。 如果您有三层(layer1,layer2,layer3),其中顶层是layer1,并且您只想响应点击事件,则可以: map.on('click', 'layer1', function(e) {...}) 如果这不是你的意思,也许可以澄清你的意思是“重叠图层”,并且“只需要为顶层的图层调用点击处理程序”。 另外,请提供您当前的代码,并举例说明问题所在。 编辑 因此,您需要一个适用于多个图层的单击事件,并与最上面的项目交互: map.on('click', function( ...
  • 我会猜测你运气不好。 浏览器限制了WebGL实例的数量。 有解决方法,但使用它们可能需要更改mapbox-gl的实现方式。 我建议你问他们是否会考虑实施其中一种解决方法,假设他们还没有。 还有另外一种可能性,那就是在JavaScript中对WebGL进行自己的虚拟化。 这可能不是一个好的解决方案,但因为它不会跨地图共享资源,而且可能太重。 在我头顶,你必须创建一个屏幕外的画布并覆盖HTMLCanvasElement.prototype.getContext这样当有人创建一个webgl上下文时,你会返回一个虚 ...
  • 此功能尚未实现。 它非常缺失。 你会考虑提交公关吗? https://github.com/mapbox/mapbox-gl-js/issues/1485 This feature is not yet implemented. It is sorely missing. Would you consider submitting a PR? https://github.com/mapbox/mapbox-gl-js/issues/1485
  • 我很接近。 这实际上起作用: