问题
I have spent a long time reading and trying to figure out git commit --amend, but I still do not understand how the # are used in the editmsg.
I am worried to edit this without knowing what I am doing because I have read that git commit --amend only does the most recent commit,and once I save and exit , it will be counted as a new commit.
I have accidentally committed and pushed (but the push failed) some large files. But I have also written scripts that were supposed to be pushed from the same commit as the large files.
I am trying to delete the lines with the large files in the new commit , but I don't understand how to do this.
This is my commit file below, but I don't understadn if I should delete the lines with the # (I tried this but it didn't work , and the git log is the same ):
the commit message of the one I want to change is here but I don't want to just change the message, I want to delete the large files in the commit so that the push works.
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Date: Thu Feb 8 18:30:32 2018 -0900
#
# On branch master
# Your branch is ahead of 'origin/master' by 1 commit.
# (use "git push" to publish your local commits)
#
# Changes to be committed:
# new file: script.py
# new file: super_large_file.npy <--- I deleted this line but it appeared again, it is becuase deleting a line with # is ignored? Do I just rewrite the stuff after the # lines?
My question is , why does deleting the line of the large file (including the # ) not work and the commit remains still wanting to push the large file?
Should I just rewrite the commit file without the # ? But I also read that git takes away the # , so I am confused
回答1:
I tried a different way than amending the commit , and removed the file completely from my local and github repositories. I am not sure how to keep it in my local repository still, but I don't know if this is necessary because I don't really understand the difference between my local repository and the local drive .
https://help.github.com/articles/removing-files-from-a-repository-s-history/
(I found this link from Bluemoon93's answer on Can't push to GitHub because of large file which I already deleted )
来源:https://stackoverflow.com/questions/48699317/what-is-a-comment-in-commit-editmsg-in-github