简体   繁体   中英

Git rename directory with submodules

Given a git repository, with a directory in which I've checked out a submodule, how can I rename the top level directory?

$ git init
Initialized empty Git repository in /home/work/asdasd/.git/
$ mkdir asd
$ touch asd/.keepme
$ git add asd/.keepme
$ git commit -a -m "asd"
[master (root-commit) 932f011] asd
  0 files changes
  create mode 100644 asd/.keep
$ git submodule add git@github.com:test/test.git asd/subdir
Cloning into 'asd/subdir'...
remote: Counting objects: 800, done.
remote: Compressing objects: 100% (281/281), done.
remote: Total 800 (delta 523), reused 786 (delta 509)
Receiving objects: 100% (800/800), 109.46 KiB, done.
Resolving deltas: 100% (523/523), done.
$ git commit -a -m "submodule"
[master e0fe8e7] submodule
  2 files changed, 4 insertions(+)
  create mode 100644 .gitmodules
  create mode 160000 asd/subdir

Now, if i try to rename the asd directory, I'm getting an error:

 $ git mv asd foo
 fatal: source directory is empty, source=asd/subdir, destination=foo/subdir

How can I rename it?

您是否尝试过mv asd foo ,然后git add -u * (u用于更新),然后提交并推送更改?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM