在本地更改后更新 github 存储库

Update github repo after local changes

我已经在我的计算机上本地更新了一个项目的文件夹结构,以使其更有条理。我删除了一些文件夹,更改了一些名称并更改了文件的位置。

但现在我无法将整个内容推送到我的 github 存储库中。

有没有一种方法可以根据我在本地所做的更改来更新存储库(主分支)? 也许 git push --force?

我做了以下步骤:

git add .

git commit

git push

导致此错误:

remote: error: File folder_name/logs/... is 140.24 MB; this exceeds GitHub's file size limit of 100.00 MB

提前致谢!

检查您是否有权执行此操作。这可能是您无法推送更改的一个原因。

始终避免使用“push --force”,这是一种非常糟糕的做法,并且在很多情况下都没有必要。

如错误所示,存在 github 文件大小限制。因此,您应该在推送之前删除此类文件。

git rm -r --cached folder_name/logs 
git commit
git push

现在解释一下,rm --cached只是将他们从被跟踪中移除。我避免了 git add . 命令,因为它会再次添加所有文件。您应该 运行 git status 并相应地添加文件。

对于以后的情况,使用.gitignore

cd /path/to/github
echo "folder_name/logs/*" >> .gitignore
git add .gitignore
git commit
git status