Git使用子模块重命名目录

时间:2012-08-17 21:03:03

标签: git

给定一个git存储库,在我检查子模块的目录中,如何重命名顶级目录?

$ 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

现在,如果我尝试重命名asd目录,我收到错误:

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

如何重命名?

1 个答案:

答案 0 :(得分:0)

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