Home > OS >  In git, is there a way to effectively reset --soft / revert; revert -n without changing history?
In git, is there a way to effectively reset --soft / revert; revert -n without changing history?

Time:10-23

OK, I think this won't be possible, but here's the scenario:

I pair program and I had to break pairs. I committed my work in progress, so the other pair could continue while I was gone, but they weren't able to work on it either. Now, it would really help to work from where I was before I committed. In other words, it would be nice if my git status looked like I ran a git reset --soft head~. But since they've already pulled, I don't want to change history by working on top of an actual git reset --soft head~.

I'm fine with that WIP commit being there. What I don't like is how my IDE shows no changes. I know I could revert then revert the revert without committing, but is there a better way?

CodePudding user response:

To avoid rewriting the pushed history of branch1, make a new branch instead:

git switch branch1
git switch -c branch2
git reset --soft @~

Now your world looks just like it did the instant before you committed branch1.

  • Related