When I started working on one of my Python projects, I forgot to add my venv
virtual environment directory to my .gitignore. Now, my GitHub repository is showing the additions and deletions from that commit and does not give me a good sense of when I made major changes (the venv
directory had 100,000+ lines of code).
I've already updated my .gitignore file and ran git rm --cached .
followed by a git add
, commit
, and push
.
Is there any way to remove the additions and deletions from all previous commits where my venv
directory changed so that GitHub will no longer count these additions/deletions in my commits? I would like to keep the parts of commits that don't include venv
and only get rid of the venv
part of the commit.
git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch venv"
请记住,这会重写分支的整个历史记录,因此您必须强行推分支,并通知所有用户,以便他们强行推分支。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.