Git revokes a submitted file

Source: Internet
Author: User

First, the question

The recent problem with git is that when git uploads a file, it adds a large 100-megabyte file to Git and performs a push operation, which prompts the error when the upload is complete.

Large Files Detected See http:git.io/iept8g for more information This is larger than githubs recommended maximum file size of 50MB

That is, git cannot upload a single file over 50M.

If not, you can fix it with the git commit--amend command, and the following 2.6 will be used.

Ii. Solutions

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

Third, remarks

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

Git revokes a submitted file

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.