我尝试:
git mv a.py b.py src/
得到
fatal: multiple sources for the same target, source=b.py, destination=src/b.py
使用-n标志就像这样git mv -n a.py b.py src/
给了我:
Checking rename of 'a.py' to 'src/b.py'
Checking rename of 'b.py' to 'src/b.py'
fatal: multiple sources for the same target, source=b.py, destination=src/b.py
Run Code Online (Sandbox Code Playgroud)
我做的事真的很蠢吗?我正在使用git版本1.6.6.1
CB *_*ley 25
这已在git的当前主分支中修复,它在v1.7.0-rc0中,但尚未在发布版本中修复.
http://git.kernel.org/?p=git/git.git;a=commit;h=af82559b435aa2a18f38a4f47a93729c8dc543d3
同时,最简单的方法是git mv单独使用文件或仅使用文件mv,然后手动更新索引,例如,git add -A如果您有合适的.gitignore模式.
Jos*_*Lee 15
只要工作目录中没有任何其他更改,最简单的方法就是自己移动它们然后再使用git add -A.看吧:
$ ls
a.py b.py
$ mkdir src
$ mv *.py src
$ git status
# Changed but not updated:
# deleted: a.py
# deleted: b.py
# Untracked files:
# src/
$ git add -A
$ git status
# Changes to be committed:
# renamed: a.py -> src/a.py
# renamed: b.py -> src/b.py
Run Code Online (Sandbox Code Playgroud)
小智 12
在Windows(posh~git):
foreach ($file in get-childitem *.py) { git mv $file.name ./src }
Run Code Online (Sandbox Code Playgroud)
适合我:
$ git --version
git version 1.6.4.1
$ mkdir foo
$ cd foo
$ git init
Initialized empty Git repository in /home/wich/foo
$ touch a b c d
$ git add a b c d
$ git commit -m "foobar"
[master (root-commit) 11051bd] foo
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 a
create mode 100644 b
create mode 100644 c
create mode 100644 d
$ mkdir bar
$ git mv a b c d bar
$ git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# renamed: a -> bar/a
# renamed: b -> bar/b
# renamed: c -> bar/c
# renamed: d -> bar/d
#
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29104 次 |
| 最近记录: |