Skip to content

commit all untracked changes, including deleted files #351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nschloe opened this issue Sep 2, 2015 · 3 comments
Closed

commit all untracked changes, including deleted files #351

nschloe opened this issue Sep 2, 2015 · 3 comments

Comments

@nschloe
Copy link

nschloe commented Sep 2, 2015

For committing all untracked changes (git commit -a) in GitPython, you have to add all dirty files to an index

index.add([diff.a_blob.path for diff in index.diff(None)])

and commit that (according to this answer on the mailing list from 2011).

Unfortunately, this doesn't work if there are deleted files. In this case, one gets

FileNotFoundError: [Errno 2] No such file or directory: 'path/to/deleted/file.txt'

Any way for dealing with this?

@Byron Byron added this to the v1.0.2 - Fixes milestone Sep 6, 2015
@Byron
Copy link
Member

Byron commented Sep 6, 2015

IndexFile.add(...) is not suited for possibly non-existing resources due to the behaviour you experienced already.
In your case, I believe it would be best to just call git directly like this: repo.git.add(update=True). repo is assumed to be the Repo instance from which you previously obtained the index as well.

Next time you have a question, you might want to consider using stackoverflow with the GitPython tag as this will drastically reduce the time it takes to receive a suitable answer.

If this works for you, please feel free to close this issue.

@nschloe
Copy link
Author

nschloe commented Sep 11, 2015

Is there a corresponding piece of documentation that you could point me to?

@Byron
Copy link
Member

Byron commented Sep 20, 2015

There is a part of the tutorial dedicated to using git directly: http://gitpython.readthedocs.org/en/stable/tutorial.html#using-git-directly.

Using the git command's porcelain is the recommended way of doing high-level tasks in GitPython.

@Byron Byron closed this as completed Sep 20, 2015
hawkeye116477 added a commit to FiltersHeroes/ScriptsPlayground that referenced this issue Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants