The workaround is to revoke this version of the file submission via git reset head~1, after which the version file is retained, but need to be added again, using the example below
1. Create a local git project
Using the git clone command, create a local git project such as
2. Add files to the project
2.1 Add 1.txt files under the project directory, perform add and commit operations, as follows
2.2 Add large files (more than 100 m) in the project directory, perform add and commit operations, as follows
2.3 Continue to add files under the project directory, perform add and commit operations, as follows
2.4 Performing a git push operation
Since the file in 2.2 is more than 50M, after executing the GIT push Origin Master command, there will be a problem at the beginning of the article, if you delete the large file, and git commit operation, after the git push will still upload the large file. This is a problem that cannot be submitted each time, so what we have to do is to undo Step 2, which does not affect the subsequent files in step 2.
2.5 undo the operation of Step 2
Using the command git reset--mixed head~2, fall back to the first step, remove Step 2, Step 3 of the file will be revoked, become waiting to add, but not lost, we just need to add once.
At this point we find that the task falls back to the first step after executing the command, we delete the large file and then execute the add command
Then execute the GIT push origin master implementation to upload the subsequent files.
2.6 Forget to delete the large file, but also after the commit operation repair.
If you forget to delete the large file and commit it directly, but only if it is not push, you can revoke the operation via the git commit--remond command, as follows
About the git reset command, including--mixed,--soft--hard etc, where--mixed is the default way, the difference between them is as follows
Git reset–mixed: This is the default, git reset without any parameters, this way, it fallback to a version, only keep the source, fallback commit and index information git reset–soft: Fallback to a version, Only the information of the commit is returned, and it is not restored to the index file level. If you want to commit, you can git Reset–hard: completely fallback to a version, the local source code will also become the previous version of the content
-soft: Canceled commit --hard: Cancel Commit, Cancel Add, cancel source file modification
Reference articles
Git undo Commit
The difference between git revert and reset