简体   繁体   中英

git push not showing on github and still lfs error

I recently made a new directory on my local and copied all my changes from another project using a different source control into this new directory.

Inside the new directory I did

git remote add origin git@github.com/user/repo.git //ssh url to my empty Github Repo

Afterwards, I did git status then git add all and git commit. Finally I did git push and I kept getting an error about a large file not being able to push to Github. For this I did git lfs install and git lfs track "*.[filename]" but this didnt seem to work so I just deleted it from my new directory. After deleting it, I did git status again and committed the deletions of these files. However, when I push, I still get the error about the large files and checking out the lfs tool. When I go into my new directory, the large files git is complaining about is not there anymore.

You might try resetting the repo back to before you first committed the large files:

git reset HEAD~2 --soft

then get things sorted out, commit , and push again.

Another way to do it would be with filter-branch , as per the git man page:

Suppose you want to remove a file (containing confidential information or copyright violation) from all commits:

 git filter-branch --tree-filter 'rm filename' HEAD

Reason this is happening is that, even though you have now removed those files, they still were part of that first commit. Git wants to keep a full history of the repository (hey, that's one of reasons you want to use it, right?) and so it keeps those files as part of that commit history.

After deleting it, I did git status again and committed the deletions of these files. However, when I push, I still get the error about the large files and checking out the lfs tool. When I go into my new directory, the large files git is complaining about is not there anymore.

I assume you mean that you did git rm on the large file. This removes the file from the current working directory and after you git commit adds a commit that shows the file was removed. However, the commit where you added the large file still remains in the history in your git repository . This means that when you git push , it will still try to push the commit that added the large file.

If you added the large file recently, you can use git reset to reset your current branch to a commit before you added it. Note that this will remove all changes since that commit. If you have other changes you want to keep, then you need to use git filter-branch or a 3rd party tool. How to remove/delete a large file from commit history in Git repository? has a very good description about how to do this.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM