amend

How to git commit --amend a commit that's the base of a branch

為{幸葍}努か 提交于 2020-06-24 11:21:11
问题 I have branch foo off of master/head. I wanted to ammend the master/head and have these changes picked up on branch foo. I did the following: git checkout master git add ... git commit --amend git checkout foo git rebase master The problem was the old non-amended commit shows up as part of branch foo after the amend, and it got rebased onto master. I did a git rebase -i and deleted the old commit and that worked, but is there an easier/safer way to modify the commit that's the base of a

Amended commits revert to previous commit

余生颓废 提交于 2020-01-25 07:28:11
问题 I have a repo with master branch. I have patch-sets 1 to 10 amended in a single commit. Now I have amended the 11th patch-set in that commit and pushed the code in gerrit. I want to revert the commit back to 10th commit and push. How do I revert, as if I see git log, it does not list the commits in that patch-set. But it rather takes it as a single commit. I have explained the sequence of actions done below. Sequence of actions 1. Initially for patch-set #1 git clone repo made changes to code

Accidentally pushed commit: change git commit message

血红的双手。 提交于 2019-12-27 18:23:00
问题 In my local repo I have one commit with an incorrect commit message. I've already published the incorrect commit message with git push . Now the remote repo (which is GitHub-hosted) has the incorrect commit message, too. I've already tried git commit --amend , but found that it will not work for me in this situation because I've made additional commits since the incorrect one. How would you fix this situation? 回答1: Easiest solution ( but please read this whole answer before doing this ): git

Accidentally pushed commit: change git commit message

落花浮王杯 提交于 2019-12-27 18:21:31
问题 In my local repo I have one commit with an incorrect commit message. I've already published the incorrect commit message with git push . Now the remote repo (which is GitHub-hosted) has the incorrect commit message, too. I've already tried git commit --amend , but found that it will not work for me in this situation because I've made additional commits since the incorrect one. How would you fix this situation? 回答1: Easiest solution ( but please read this whole answer before doing this ): git

What is a comment in commit_editmsg in github

喜欢而已 提交于 2019-12-24 22:25:12
问题 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

Git: How to edit/reword a merge commit's message?

℡╲_俬逩灬. 提交于 2019-12-18 09:56:11
问题 How do I edit or reword a merge commit's message? git commit --amend works if it's the last commit made ( HEAD ), but what if it comes before HEAD ? git rebase -i HEAD~5 doesn't list the merge commits. 回答1: If you add the --preserve-merges option (or its synonym, -p ) to the git rebase -i command then git will try to preserve the merges when rebasing, rather than linearizing the history, and you should be able to amend the merge commits as well: git rebase -i -p HEAD~5 回答2: Note that,

Edit the root commit in Git?

孤街浪徒 提交于 2019-12-16 20:09:05
问题 There's ways to change the message from later commits: git commit --amend # for the most recent commit git rebase --interactive master~2 # but requires *parent* How can you change the commit message of the very first commit (which has no parent)? 回答1: Assuming that you have a clean working tree, you can do the following. # checkout the root commit git checkout <sha1-of-root> # amend the commit git commit --amend # rebase all the other commits in master onto the amended root git rebase --onto

How to undo the initial commit on a remote repository in git?

廉价感情. 提交于 2019-12-06 19:56:33
问题 If my very first commit is wrong, yet pushed to a (currently private) remote, how do I undo that commit on the remote? I'm guessing I can just amend and then push --force? 回答1: By deleting your HEAD you can restore your repository to a new state, where you can create a new initial commit: git update-ref -d HEAD After you create a new commit you will need to force it to the remote in order to overwrite the previous initial commit: git push --force origin 回答2: If you've just one commit (initial

How to undo the initial commit on a remote repository in git?

ⅰ亾dé卋堺 提交于 2019-12-05 01:20:21
If my very first commit is wrong, yet pushed to a (currently private) remote, how do I undo that commit on the remote? I'm guessing I can just amend and then push --force? By deleting your HEAD you can restore your repository to a new state, where you can create a new initial commit: git update-ref -d HEAD After you create a new commit you will need to force it to the remote in order to overwrite the previous initial commit: git push --force origin If you've just one commit (initial commit), you can do as git commit --amend git push --force origin 来源: https://stackoverflow.com/questions