Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Git Move failure when using wildcards #1445

Unanswered
agirault asked this question in Q&A
Discussion options

Hoping to move all files from the foo folder to the current folder (.)

The raw git command looks like this: git mv foo/* .

Using GitPython, those are the two alternatives I could attempt:

repo.index.move(['foo/*', '.']) # -> cmdline: git mv --dry-run foo/* .
repo.git.mv('foo/*', '.') # -> cmdline: git mv foo/* .

They both return the same error:

git.exc.GitCommandError: Cmd('git') failed due to: exit code(128)
 stderr: 'fatal: bad source, source=foo/*, destination=*'

What is surprising to me is:

  • error says "bad source" but the generated cmdline looks good and actually works when running them in the terminal
  • destination input is . but stderr shows *
You must be logged in to vote

Replies: 1 comment

Comment options

repo.git.mv(...) should work the same as on the command-line. The latter will resolve the * portion as it runs in the shell, but in theory at least, * also is a glob picked up by git which should resolve it internally. You could try to run git mv 'foo/*' . (note 'single quotes') in the terminal to see if it yields the same result as what you see in GitPython.

If so, this means that git does not resolve the glob for some reason even though I would expect it to do that.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1443 on May 21, 2022 01:54.

AltStyle によって変換されたページ (->オリジナル) /