How to discard a history commit before git push

Source: Internet
Author: User

Today wrote a day code, and then Git hub commits up to 7 times, but none of the changes are formally pushed up. The result of the final push is found in the middle of a commit file over 100M. Is the Code performance analysis report for vs. vsp file, I can only say really is gigantic, a report actually has 800M. Of course I want to ignore this file, so modify the. gitignore file. But it is too late, because the previous commit already has this file, even if I ignore it in the new commit, the previous commit can not be pushed up. Then you have to abandon all the commits without a face. Re-come.

1. First back up all of today's changes.

2. Discard all commits:

A. Copy the head version of the SHA from master

b. Git reset--hard SHA

3. Copy today's changes, note that only copy code changes, do not copy the relevant git files back, or git will say your branch is ahead of the Master 7 commits Blablabla ...

4. Then resubmit the code. Git add-a, git commit-m "Your log", Git push

Finally mention a wake up, if there is a change the best or direct push up good, or to the last tired is their own. Today's code did not write a few lines, do git. Sad.

How to discard a history commit before git push

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.