开发者

changing git directory to previous one

开发者 https://www.devze.com 2023-01-12 04:10 出处:网络
I have a project directory like /projects/myProject/src/... and my git repository is on /projects/myProject/src directory. But I want to change my main git directory to /projects/myProject(which is th

I have a project directory like /projects/myProject/src/... and my git repository is on /projects/myProject/src directory. But I want to change my main git directory to /projects/myProject(which is the 开发者_如何学运维parent of current git directory.) I could just create a new repo on /projects/myProject, but I could lose all of my previous commits. Is there a way to change my directory without loosing my commit data?


  1. Within the /src folder, Perform a move of * to ./src so now your code should all be in /src/src. If you do the move correctly it'll keep all the revision history.
  2. Move all content from /myproject/ to /myproject/src and then commit it.
  3. Rename /myproject/src to /myproject/myproject and then move the entire directory tree down one.

That should retain your commit history.

Example

Before:

  • /Myproj.make
  • /src/.git
  • /src/myproj.cpp

Next Step:

  • /Myproj.make
  • /src/.git
  • /src/src/myproj.cpp

Next Step:

  • /src/.git
  • /src/Myproj.make
  • /src/src/myproj.cpp
  • [COMMIT]

Next Step:

  • /.git
  • /Myproj.make
  • /src/myproj.cpp
  • [DONE]
0

精彩评论

暂无评论...
验证码 换一张
取 消