如何在不妨碍我的团队的情况下重命名根项目文件夹?

时间:2023-01-13 12:03:53

The root folder of our repository has a space in it.
I'd like to make a pull-request that replaces this space with an underscore.

我们的存储库的根文件夹中有一个空格。我想制作一个拉取请求,用下划线替换这个空间。

As you know, git does not store directories; only filenames. Therefore, this change will affect every source file in our codebase.

如你所知,git不存储目录;只有文件名。因此,此更改将影响我们的代码库中的每个源文件。

How can I make this change while giving my coworkers the least amount of problems?

如何在为同事提供最少量的问题的同时进行此更改?

All of our developers branch off of a single branch named dev, and my change will also need to occur on a sub-branch of dev.

我们所有的开发人员都分支了一个名为dev的分支,我的更改也需要在dev的子分支上进行。


Here are my desired goals, and current restrictions.

这是我期望的目标和当前的限制。

goals:

目标:

  • minimal hindrance on other developers. (We have hundreds of active branches, some of which are pull-requests).

    对其他开发者的最小障碍。 (我们有数百个活动分支,其中一些是拉取请求)。

  • preserve history. (Ideally, I'd like this change to showup as a rename, or a move on the individual file's history).

    保存历史。 (理想情况下,我希望将此更改显示为重命名,或者移动单个文件的历史记录)。

  • minimal merge conflicts (if possible)

    最小的合并冲突(如果可能)

  • avoid unintentional side effects (there may be details I'm not aware of. I should note that we have developers on both windows and linux- although this is not a case sensitive file change.)

    避免无意的副作用(可能有我不知道的细节。我应该注意到我们在Windows和Linux上都有开发人员 - 尽管这不是区分大小写的文件更改。)

restrictions:

限制:

  • I don't have access to directly change the dev or master branch.
  • 我没有权限直接更改dev或master分支。
  • cannot perform any force pushes (so I won't be able to rewrite history).
  • 不能执行任何强制推送(所以我将无法重写历史记录)。

1 个解决方案

#1


1  

You can rename the directory using the git mv command. This will work as expected, and preserve history, etc. Even if other changes occur to the files under this directory hierarchy before your rename is merged, it shouldn't cause any problems.

您可以使用git mv命令重命名目录。这将按预期工作,并保留历史记录等。即使在合并重命名之前,此目录层次结构下的文件发生了其他更改,也不会导致任何问题。

First, rename the directory:

首先,重命名目录:

git mv olddir newdir

Then use git commit to commit the change.

然后使用git commit提交更改。

#1


1  

You can rename the directory using the git mv command. This will work as expected, and preserve history, etc. Even if other changes occur to the files under this directory hierarchy before your rename is merged, it shouldn't cause any problems.

您可以使用git mv命令重命名目录。这将按预期工作,并保留历史记录等。即使在合并重命名之前,此目录层次结构下的文件发生了其他更改,也不会导致任何问题。

First, rename the directory:

首先,重命名目录:

git mv olddir newdir

Then use git commit to commit the change.

然后使用git commit提交更改。