For example, you can simply right-click the commit you want to change and select "Edit Commit Message". If you want easy access to advanced Git tools like "interactive rebase", the Tower Git client can be helpful. You should definitely understand what you're doing before applying it! See here if you really need to use it. The "interactive rebase" command, however, is quite an advanced tool: very powerful and a tiny bit dangerous. If you want to change older commits, Git also has a tool for this use case: $ git rebase -interactive In case you are using the Tower Git client, amending your last commit is easily possible right from the commit area interface: Changing Older Commits Therefore, use "amend" whenever you want to change / edit your very last and unpushed commit. This makes it very important that you don't amend (= rewrite) commits that you've already published to a remote repository! Because in that case, your colleagues might have already based their work on this commit - which you would try to replace using "amend". Amend rewrites the commit history in your repository: the old commit is replaced by a completely new one (a new and different commit object).You can add a co-author by adding a trailer to the commit. 3 In your text editor, edit the commit message, and save the commit. If you notice your mistake only after adding another commit, amend won't help you much. Commit has not been pushed online 1 On the command line, navigate to the repository that contains the commit you want to amend. Amend only works with the very last commit.However, keep two important details in mind: This also means that you're not limited to just editing the commit's message: you could also add another couple of changes you forgot. Simply put, this overwrites your last commit with a new one. To change the last commit, you can simply commit again, using the -amend flag: $ git commit -amend -m "New and correct message" Download Now for Free Amending the Last Commit
0 Comments
Leave a Reply. |