问题标签 [renaming]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
6004 浏览

git - Alternative to git cherry-pick when renamed files are common

I'd like to cherry-pick single commits from on branch to another. I expect file renames to be quite common but still want to be able to apply changes without human intervention.

Since the built-in cherry-pick command doesn't seam to detect renames (at least in my test cases), especially when combined with modification to the renamed file.

I tried a bit and finally came up with a solution involving two rebase operations.

Let's assume I have a branch named target pointing at the commit I want to apply the cherry-pick to. The commit I want to cherry-pick is pointed to by a branch named source.

I then execute the following commands:

  1. create branch sourceTemp pointing at the same commit as source (since I want to retain the branch source )
  2. git rebase --strategy="recursive" --strategy-option="rename-threshold=30" target sourceTemp (maybe use another threshold; the test file was quite small and the changes therefore relatively large)
  3. git rebase --onto target sourceTemp~ sourceTemp

This applies only the changes introduced by the last commit in branch source to target.

I also put my test on github:

https://github.com/fraschfn/cherry-pick

What I like to know is, if this approach is feasible or if it only worked in my simple test setting!

Update: Alternative method

I rebase the patch to the merge base of source and target:

start situation

I want to cherry-pick D onto B.

  1. rebase D onto M after creating a new branch patch

    /li>
  2. merge C and D' to obtain a replacement for source

    merge B and D' to obtain the patched version of target

    /li>

The advantage is that E and F can now be merged without a problem. Alternative way: Include the patch as early as possible in the hierarchy thus not creating D but directly D' and saving yourself the rebase.

The advantage above the previous version is that you can merge the two branches "new source" and "patched target" and it will work (if the merge of source and target would work of course) and not introduce the same changeset twice since git knows due to the merge operation which introduced the changeset into both branches.

0 投票
1 回答
23345 浏览

c# - 如何在 Visual Studio 2008 中重命名现有解决方案和项目?

可能重复:
如何在不终止解决方案的情况下重命名项目

我知道这个问题经常被问到,但没有人能帮助我克服因不当重命名我的解决方案而使我的应用程序无用的恐惧,

我正在 VS 2008 中开发 C# Windows 应用程序,因为在最初的步骤中,我不知道重命名在 VS 中是一个如此大的问题,我命名了该项目"stock",但现在我的项目已接近完成,我的领导想要重命名命名空间,BetRates_NS因为这是部署设置项目的名称,

我什至在我的解决方案中有 Web 服务引用和其他具有命名空间名称的依赖项,根据我以前的经验,在 VS 中重命名并不是那么容易,

所以有人可以给我重命名我的解决方案的确切分步过程,以便应用程序现在可以顺利运行,并且可能不会因此在以后的时间点崩溃。

我完全希望在这里得到一些帮助.....thanxx提前......!!

这是我的解决方案资源管理器屏幕:

在此处输入图像描述

0 投票
2 回答
1605 浏览

unix - Unix-在重命名文件时将相同文件从多个目录复制到新目录

我在名为 10,11,12,....45 的同一目录中有 36 个子目录和一个子目录 logs

在每个子目录(目录日志除外)中都有一个名为 log.lammps 的相同文件

我想知道是否有一种方法可以从每个子目录 10-45 复制每个 log.lammps 文件并将其放入子目录日志中,同时还将其源自的目录的编号添加到文件名的末尾

所以我正在寻找一个从每个子目录一个接一个地复制文件 log.lammps 的代码,每次文件被复制到目录日志中时,如果它来自子目录,文件名就会从 log.lammps 更改为 log.lammps10 10 并且当子目录 11 中的文件 log.laamps 被复制到日志中时,其名称更改为 log.lammps11 等。

任何帮助将不胜感激,因为现在我只处理 30-40 个文件,并且及时我将处理数百个文件

0 投票
0 回答
792 浏览

android - 更改 Android 应用的文件夹名称

我有一个 android 应用程序(带有 jni、ndk)。我想改变它的名字。我已经成功更改了包名称,以及 strings.xml 中的应用程序标题,如本论坛其他帖子中所建议的那样。

但是 .apk 文件仍然具有旧名称。我猜这是因为主文件夹仍然具有旧名称。如果我在 eclipse 中更改文件夹名称并“更新引用”。我收到以下错误。

所以我猜它混淆了ndk-build。如果我查看 C++ 的项目属性,一切看起来都很正常(我认为)。构建路径是 ${workspace_loc:/NewName}。

关于检查什么的任何想法?

谢谢!


更新

好的,ndk-build 命令在命令行中运行良好。但是,如果我只从 eclipse 编译本机 c++,它会给我错误。我猜项目属性中的某些内容是错误的......

当我禁用代码检查时,项目运行良好。c++ 似乎也停留在 std 命令上。尽管我已经在我的路径中添加了三个库,如此处所述Native c++ with Android on Eclipse - 在 stdlib 上给出错误但可以工作并且它们被定义为绝对路径,例如 /home/dorien/workspace2/android-ndk-r8/sources /cxx-stl/stlport/stlport

0 投票
3 回答
647 浏览

encryption - md5 的替代品(不适用于密码散列)

所以我想生成一些缓存的 html 文件,并且我想在命名它们时使用某种加密,这样它们就不能被轻易访问。Md5/Sha1,2 可能是不错的选择,但我想要一些轻巧的东西,它会生成一个字符串让我们说 12 个字节长(只是说)。

有没有类似的东西,在 php 中可用?

谢谢你。

0 投票
2 回答
478 浏览

bash - 使用重命名命令在第二个下划线后重命名

我有一个名为“ABI-Data”的目录,其中包含如下文件

我需要像这样的输出

简而言之,我想用字符“abi”或任何东西将所有文件重命名为分数下的第二个。

我尝试在工作目录中使用重命名命令ABI-Data

但发现错误如

请建议我在哪里做错了,或者建议我命令/脚本/代码将所有字符截断到第二个下划线并abi在每个文件名中添加后缀。

0 投票
1 回答
444 浏览

java - 为什么tomcat不知道在eclipse中重构包名

我在我的 JAVA 项目中更改了几个包名称,但是在更改后再次启动 tomcat 时,它会尝试获取旧的包名称。(抛出 java.lang.ClassNotFoundException)

尝试重新构建我的应用程序时出现以下异常:

我究竟做错了什么?是否还需要更改 tomcat 属性中的某些内容?

提前致谢!!

0 投票
2 回答
1049 浏览

vb.net - VB.NET 如何重命名 MemoryStream 中的图像?

好吧,标题几乎说明了一切。如果我在文件流中有这样的图像:

我如何将此文件重命名为我制作的 GUID。现在这是我正在尝试的方法,但是“sd”被突出显示并说“'System.Drawing.Bitmap'类型的值不能转换为'String'”

这是制作 GUID 的代码:

这是重命名的代码...

我敢肯定这是愚蠢的,但任何帮助将不胜感激!另外,我是个十足的菜鸟!因此,如果它完全错误,请不要讨厌哈哈。提前致谢!

此外,如果需要,这里是如何生成图像的代码(它正在拍摄桌面图像):

0 投票
2 回答
696 浏览

bash - 在 bash 中重命名文件的陷阱

我正在阅读此链接上的指南 http://mywiki.wooledge.org/BashFAQ/030 给出了一些示例 我试图理解它们 一个示例代码说

到目前为止,我所知道的是在搜索和替换示例或在上面示例中的 shell 脚本中使用反斜杠来表示特殊字符,例如 ~ 或 # 等空格,他们
使用 ${f// /_}
了正斜杠,我不清楚这是允许吗?
在同一页面上的另一个示例中,他们给出了一个删除空格并将其替换为下划线的示例

find . -depth -name "* *" -exec bash -c 'dir=${1%/*} base=${1##*/};
mv "$1" "$dir/${base// /_}"' _ {} \;

在上面的例子中,我不清楚下面的
1) dir=${1%/*}
2) base=${1##*/}
3),当它mv "$1"在上面的语句中说明 $1 的含义时,
4) 最后 find 命令正在关闭,-exec <something> _ {} \;
现在下划线 _ 的用途是什么,卷曲大括号 {} 和一个反斜杠,后跟一个冒号 \;?
在第三个例子中,他们说

我不清楚以下几行
5)[ -f "$file" ] || continue # ignore non-existing names
我不清楚 [ ] 如果 $file 存在则测试条件,那么 OR 条件有什么用 || 这里和继续声明
6)[ -f "$newname" ] && continue # don't overwrite existing files这里的疑问与第 5 点相同

0 投票
1 回答
38202 浏览

batch-file - 如何批量更改子文件夹中的文件扩展名

我对命令提示符很陌生,直到 1 天前才开始使用它。

例如,我在某个位置有一个文件夹,C:\Users\Administrator\Desktop\Images在该文件夹内大约有 650 个子文件夹,每个子文件夹包含大约 20 张图像,混合了 JPG 和 PNG。我正在为 CMD 寻找一个命令行,它将遍历所有子文件夹并将每个.png文件更改为一个.jpg文件。

我做了一些研究并找到了一些信息,但是很难理解和理解,我仍然无法做到。我想保留文件名,但是将每个文件扩展名从 a 更改.png为 a .jpg

我知道对于 1 个文件夹,该行类似于ren *.png *.jpg. 但是,这不会将更改应用于子文件夹。