Sourcetree Amend

  1. Sourcetree Amend Commit Message
  2. Sourcetree Amend Pushed Commit Message
  3. Sourcetree Amend Commit
  4. Sourcetree Amend Old Commit
If you wish to undo a prior git commit, there are a few ways to go about it. Are you trying to:
  • Amending the Last Commit. To change the last commit, you can simply commit again, using the -amend flag: $ git commit -amend -m 'New and correct message' Simply put, this overwrites your last commit with a new one. This also means that you're not limited to just editing the commit's message: you could also add another couple of changes you.
  • Oct 05, 2019 Adding the amend option you will replace the tip of the current branch by creating a new commit. For doing this in Sourcetree you need select the Commit Options in the right top of the commit input box and select the option Amend last commit.
  • Amend commit message in SourceTree If you’re using Atlassian SourceTree with a git repository and you do a local commit but then realise the message was incorrect, you can amend it before you push it to remote. To set this up, you can create a “Custom Action” in SourceTree: Tools - Options - Custom Actions.

It's simply a matter of hitting the 'edit commit' (or was it amend? When SourceTree drops back out during the interactive rebase process to allow you to edit then you can re-commit hitting the 'amend commit' option in the commit view but changing the author from there instead. This actually creates a whole new commit SHA, too.

  1. Undo the exact changes introduced by a git commit,
  2. undo part of a git commit, or
  3. remove the changes from git history

Git Revert

The most straightforward way is to use git revert. GUI front-ends for git such as SourceTree, has an option to revert a commit. Simply right-click on the commit you wish to undo, and select Reverse commit..

Sourcetree Amend Commit Message


You will be asked to confirm, after which a new commit will be created



The git command line equivalent is:

More information on the git revert syntax.
You really should amend the new commit's message to explain why the earlier git commit is reverted. In SourceTree, click on Commit and select Commit options.. > Amend last commit, then type in the reason

Manually Undo

Sourcetree Amend Pushed Commit Message

If the changes are relatively simple, you are better off editing the source files directly and creating a new commit. This includes mistakes and typos that you have made; it is perfectly normal to create new commits.
Note that I am not suggesting making constant commits for any and every bit of changes. You ought to test the result of your changes and at least run through your unit tests (you used automated testing, don't you?) before committing.
To avoid littering your git history with unnecessary commits, consider squashing your commits if you have not pushed them. Note that you are re-writing git history; it is almost always a bad idea unless you know what you are doing. Read this article before proceeding.

Delete A Commit

Sourcetree Amend Commit

You can use git reset to delete a commit. Don't do this! It is almost always a bad idea to re-write git history. Especially if you have pushed your commit, you are going to mess up everyone else's git history as well.
If you have run into trouble with git commits, this comprehensive article should have a solution for you. Sourcetree

Related articles

Sourcetree Amend Old Commit

  • So You Want Your Team To Start Using Git? - Part 4: Team Workflows (java.dzone.com)
  • Scott Johnson: git transfusion (jwir3.com)
  • Git is Way Too Complex (gilbert.pellegrom.me)
  • Git Tutorial - Git Fu With The Command Line (raywenderlich.com)
  • Untangled development with Git Essentials - webinar recap (blogs.atlassian.com)
  • Using Pull Requests as Code Reviews (code.tutsplus.com)
  • Status:Needs Triage(View Workflow)
  • Resolution: Unresolved
  • Fix Version/s: None
  • Labels:
  • Environment:

There seems to be an issue around how the interactive rebase resumes after you do an amend commit.

Steps to reproduce:

  • Open two seperate git projects windows in sourcetree
  • On one of the projects, start an interactive rebase (I did this by right clicking a commit on the branch graph and selecting 'Rebase children of {commit hash}

    interactively')

  • In the dialog that opens, select a commit to amend
  • Click OK
  • Git HEAD should now be set to the commit you wish to amend.
  • Commit a change.
  • The rebase should now continue

What should happen:
The rebase should finish successfully.

What actually happens:
The rebase finishes successfully, but for every other project that is open (or has been opened since sourcetree was launched), it will attempt to do a rebase on those projects.

If those projects weren't in the rebase state, it would throw up an error dialog saying theres 'Errors during Merge. No rebase in progress?'. If those projects were in a rebase state, it should try to continue the rebase.

Ide

Votes:
0Vote for this issue
Watchers:
2Start watching this issue