5
How do I add new files to a commit already done in Git without creating a new commit?
If you have already pushed to the remote server, like "re-commit"?
5
How do I add new files to a commit already done in Git without creating a new commit?
If you have already pushed to the remote server, like "re-commit"?
9
If you do --force
, and other authors have created new commits however, these commits will be permanently erased. --force
is recipe for disaster and should be avoided at all costs.
--amend
is recommended only if the commit has not yet been published.
Since in this case the commit has already been published, it’s best to create a new commit with the new files. amend
is to rewrite history, is lie to git.
6
You must use the parameter --amend
, if it’s the last commit
git commit --amend
git add file2.txt
And when you push use:
git push --force <repository> <branch>
Reference: https://www.atlassian.com/git/tutorials/rewriting-history/git-commit--amend/
Browser other questions tagged git commit
You are not signed in. Login or sign up in order to post.