0 votes
1 view
in Devops and Agile by (28.1k points)

In one of my development branches, I made some changes to my codebase. 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 this possible?

1 Answer

0 votes
by (48k points)

git reset --soft HEAD~1

And this will delete the recent commit and it doesn’t do anything to your work.

Refer: https://git-scm.com/docs/git-reset#Documentation/git-reset.txt---soft

Or there is a way you can use without using --soft option

Use 

git reset HEAD^

Which moves your HEAD to point to the specified commit, without changing any files

And HEAD^ refers to the parent commit of your current commit.

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...