如何将.git文件夹移动到父文件夹而不丢失历史记录?

时间:2015-12-11 17:54:27

标签: git

我的本​​地git存储库看起来像这样

C:\MyRepo
      \MyProject
           \.git
           \ProjectFolder1
           \ProjectFolder2
           \ProjectFolder3

现在我想添加几个需要直接在“MyRepo”下的文件夹,并且需要成为同一个存储库的一部分。我想这意味着.git文件夹也应该直接在“MyRepo”

C:\MyRepo
     \.git
     \NewFolder1
     \NewFolder2
     \MyProject
           \ProjectFolder1
           \ProjectFolder2
           \ProjectFolder3

如何移动.git文件夹,不用丢失历史记录。我正在使用Windows操作系统。 和git版本是2.6.3.windows.1

2 个答案:

答案 0 :(得分:3)

在移动git repo之前,您可以将所有文件移动到内部cd C:\MyRepo\MyProject mkdir MyProject git mv -k * MyProject git commit move .git .. cd MyProject move * .. cd .. rmdir MyProject cd .. git add NewFolder1 NewFolder2 git commit 文件夹。这样的事情可能有用:

Exception in thread "main" java.lang.NoClassDefFoundError: scala/reflect/Manifest$
    at org.json4s.ext.DurationSerializer$.<init>(JodaTimeSerializers.scala:41)
    at org.json4s.ext.DurationSerializer$.<clinit>(JodaTimeSerializers.scala)
    at org.json4s.ext.JodaTimeSerializers$.all(JodaTimeSerializers.scala:26)
    at com.xxx.dts.toolset.jsonWrite$.jsonClob(jsonWrite.scala:21)
    at com.xxx.dts.dq.profiling.DQProfilingEngine.profile(DQProfilingEngine.scala:253)
    at com.xxx.dts.dq.profiling.Profiler$.main(DQProfilingEngine.scala:58)
    at com.xxx.dts.dq.profiling.Profiler.main(DQProfilingEngine.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.apache.spark.deploy.SparkSubmit$.org$apache$spark$deploy$SparkSubmit$$runMain(SparkSubmit.scala:569)
    at org.apache.spark.deploy.SparkSubmit$.doRunMain$1(SparkSubmit.scala:166)
    at org.apache.spark.deploy.SparkSubmit$.submit(SparkSubmit.scala:189)
    at org.apache.spark.deploy.SparkSubmit$.main(SparkSubmit.scala:110)
    at org.apache.spark.deploy.SparkSubmit.main(SparkSubmit.scala)
Caused by: java.lang.ClassNotFoundException: scala.reflect.Manifest$
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    ... 16 more

另见How to import existing Git repository into another?

答案 1 :(得分:0)

要考虑的重要一点是,存储库的父文件夹名称与该存储库无关。

  1. 将“ MyRepo / MyProject”重命名为“ MyRepo / tmp”
  2. 创建一个新文件夹“ MyRepo / tmp / MyProject”
  3. 将所有(“ .git”除外)从“ MyRepo / tmp”移动到“ MyRepo / tmp / MyProject”
  4. commit -m“将所有内容移至MyProject”
  5. 将所有内容(包括“ .git”)从“ MyRepo / tmp”移至“ MyRepo”
  6. 删除“ MyRepo / tmp”