![]() I also have some changes which are not committed yet. *commit N+20 <- branch fb/abc, origin/dev-abc *commit N+22 <- branch dev-abc(HEAD) // how the graph appears locally It suggests me to git pull those changes first(I think it is the additional commit that was created on the GitHub(whose message I want to change)). Whenever I try to push, I get an error message saying, I have some changes in remote which are not present locally. ![]() There is one more thing, I made two additional commits locally which I haven't pushed yet. In your text editor, edit the commit message and save the commit. I need to change the commit message for this commit. 9 Answers Sorted by: 177 GitHub's instructions for doing this: On the command line, navigate to the repository that contains the commit you want to amend. After doing this, you may fix the identity used for this commit with: git commit -amend -reset-author. Run the following command and follow the instructions in your editor to edit your configuration file:' git config -global -edit. This created a new commit in GitHub which is not present in my local copy. You can suppress this message by setting them explicitly. (WHY?)Īnyway, I resolved all the conflicts in the GitHub conflict resolver itself. Now, I pushed all these changes to remoteĪt this point, while creating a Pull Request, I got a merge conflict in one of the files. *commit N+20 <- branch fb/abc, dev-abc(HEAD) So this was a simple fast forward merge.Īt this point, the graph looks like this. No other changes were made to the dev-abc branch. Then I ran the following commands: git checkout dev-abc *commit N <- branch dev-abc, origin/dev-abc //created another feature branch from here "fb/abc" If you use -no-edit the comment is reused in the amended commit, else you must introduce a new comment (because it is a new commit and every commit needs a comment).įor more information about the staging area and working directory, see Reset Demystified.*commit N+20 <- (HEAD)branch fb/abc(i made 20 commits in this branch) For this, git commit -amend should not be used with pushed commits. It will generate a new commit and hence a new id for the amended commit. The files to add are those were into the SA before the git reset -soft was landed, and after reset these files are kept in the working directory (WD), so it is necessary add them to the SA for generate the amended commit. It makes git add with all files to add to new commit (it will be the amended commit).Everything keep how it was before the git commit command were used. It makes git reset - soft for bring back changes committed in the last commit (commit to amend) to the SA and move the index to previous commit (commit before commit to amend). ![]() However, commit 31b8e would now be unreachable.Īccording to my knowledge, amend works thus:įor git commit -amend works the changes to amend must be into the stagging area (SA) ![]() Git reset -hard put you in the following situation: ![]() Or (assuming you haven't, in the meantime, made any new commit on master, reset master, or otherwise moved the master branch reference) git checkout master # just to be sure that master is the current branch Running git checkout master # just to be sure that master is the current branch It still lives in your repository's object database, but it will eventually be deleted for good, when Git runs its periodic housekeeping, or if you trigger it explicitly by running git gc (garbage collection).Īddendum (based on Jason Baker's comment): Note that, as long as the amended commit, f42c5, still exists in your repository and you have a way of finding out its commit ID (for example, by fishing it out of the master branch's reflog), you can still check it out. Note that the amended commit ( f42c5) is now unreachable from any reference in your repository (hence its "transparent" style on my graph). The master branch reference is moved to point to that new commit ( 31b8e).Its parent(s) will be the same as that (those) of the commit you're amending: f42c5. Your staging area-which, if you haven't staged any new changes, will be identical to commit f42c5-is used to create a new commit: 31b8e.Write a commit message, save and quit your editor, the following happens: Assume that you're in a clean working state and that your repository looks as follows: ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |