Description Usage Arguments Details Value Examples
Undo the most recent commit WHILE LEAVING ALL YOUR FILES ALONE, combine those changes with the currently staged changes, and make a new commit. If nothing is currently staged, this is just a way to edit the most recent commit message. This function is "working directory safe" but "history unsafe". Think twice before "amending" a commit that you have pushed (see Details).
1 |
message |
The commit message. If not provided and |
ask |
Whether to confirm that user wants to change history |
repo |
Path to a Git repo. If unspecified, current working directory is checked to see if it is or is inside a Git repo. |
git_amend()
will not change your files. It gives you a do over on your
most recent Git commit. When might you use this? If you realize the most
recent commit included the wrong file changes or had a bad commit message. If
you're not ready to re-commit yet, use git_uncommit()
to just
undo the commit.
When might you NOT want to use this? If you have already pushed the most recent commit to a remote. It could still be OK if you're sure no one else has pulled. But be prepared to force push in this situation.
git_amend()
addresses the fourth most up-voted question on
StackOverflow:
Edit
an incorrect commit message in Git, with over 1.7 million views. It is
equivalent to git commit --amend -m "New commit message"
.
SHA of the commit. The when
attribute holds the commit time as
POSIXct
. An excerpt of the commit message is in the msg_start
attribute.
1 2 3 4 5 6 7 8 9 10 11 12 13 | repo <- git_init(tempfile("githug-"))
owd <- setwd(repo)
write("Are these girls real smart or real real lucky?", "max.txt")
git_commit("max.txt", message = "lines from max")
write("Did I hear somebody say \"Peaches\"?", "jimmy.txt")
git_commit("jimmy.txt", message = "lines from some guy")
git_history() ## note the SHA of the most recent commit
## fix the previous commit message
git_amend(message = "lines from jimmy", ask = FALSE)
git_history() ## note the SHA of most recent commit has changed
setwd(owd)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.