When I perform repo.index.add('.') gitpython adds .git directory...
The question is how can I add all changed files to stage without including the .gitdir?
Thanks for this great project. :)
I think the easiest would be to call the git command directly, such as in:
import git
r = git.Repo()
r.git.add(u=True)
Of course this functionality could also be emulated using pure-python, but unless you want to do special processing, I don't think it's worth the effort, both for the developer or for the CPU.
To answer your question, repo.index.add(...) is low-level enough to unconditionally add all paths given in the items iterable, and therefore it is not suited to emulate something like git add -u.
In future, you might consider using stackoverflow along with the GitPython tag as it usually yields better answers, faster.
Please close this issue if your problem is solved.
You can watch the development stream on youtube.
_GitPython #3 [answer issue 292 - using git add -u]_
Yes, it solves for me, repo.git.add(u=True) or repo.git.add('--all')
Great video by the way. ;)
Just a note for anyone else who stumbles onto this and might make the same mistake.
repo.git.add(u=True) is not the same as git add . as it does not add untracked files. Use repo.git.add(A=True) instead.
I find repo.git.add(all=True) the nicest.
Thanks @Byron This was really helpful
Most helpful comment
Just a note for anyone else who stumbles onto this and might make the same mistake.
repo.git.add(u=True)is not the same asgit add .as it does not add untracked files. Userepo.git.add(A=True)instead.