0

I made some changes to my code-base. Before I was able to complete the features I was working on, I had to switch my current branch to master to demo some features. But just using a "git checkout master" preserved the changes I also made in my development branch, thus breaking some of the functionality in master. So what I did was commit the changes on my development branch with a commit message "temporary commit" and then checkout master for the demo.

Now that I'm done with the demo and back to work on my development branch, I would like to remove the "temporary commit" that I made while still preserving the changes I made. Is that possible?

Bilal Ahmed
  • 4,005
  • 3
  • 22
  • 42
  • 1
    Possible duplicate of [How can I unstage my files again after making a local commit?](http://stackoverflow.com/questions/6682740/how-can-i-unstage-my-files-again-after-making-a-local-commit) – LeGEC Apr 12 '17 at 09:11

2 Answers2

3

Yes, the command you are looking for is git reset

git reset HEAD^   # HEAD^ is one of the numerous ways to say :
                  # the parent of current commit
LeGEC
  • 46,477
  • 5
  • 57
  • 104
1

you can do: git reset --soft HEAD^

this will reset the last commit you made and preserve all changes done in the commit. But your Changes will still be staged.

If you want to unstage them you can also use git reset afterwards to unstage all files. Your changes are still there.

Stefan F.
  • 608
  • 7
  • 15