Bureaucrats, confirmed, Administrators
4,558
edits
(add references) |
(adds simple pointer on removing contents from previous commit) |
||
Line 6: | Line 6: | ||
You forgot to add a file to the last commit? Just add it to the index, and commit with <code>--amend</code>. If you leave off the -m (message) option in the new commit, it will let you re-use the last commit message. This lets you "undo the last commit" and redo it right. You usually do not want to amend a commit if you've already pushed it to other repos, but if it's just local <code>--amend</code> is awesome-sauce. | You forgot to add a file to the last commit? Just add it to the index, and commit with <code>--amend</code>. Added a file that shouldn't be there? <code>git rm</code> it. If you leave off the -m (message) option in the new commit, it will let you re-use the last commit message. This lets you "undo the last commit" and redo it right. You usually do not want to amend a commit if you've already pushed it to other repos, but if it's just local <code>--amend</code> is awesome-sauce. | ||
<source lang="bash"> | <source lang="bash"> | ||
git add forgotten.php | git add forgotten.php | ||
git rm oops.txt | |||
git commit --amend | git commit --amend | ||
git log --stat | git log --stat |