Home > Software engineering >  IntelliJ Gitlab revert to older branch locally without affecting remote branches
IntelliJ Gitlab revert to older branch locally without affecting remote branches

Time:12-14

I want to use the IntelliJ windows Gitlab menu interface under Git menu heading to revert to an older branch from the remote repository. I want to do this locally without affecting the remote branches. Therefore, when I do this, unless I check something in, the current remote branch should remain in place completely as is.

I currently do not have any local work that needs to be saved.

How do I get the older version, as described above without affecting the remote repository?

CodePudding user response:

You should just do this using git or the VCS/git IntelliJ features. Just reset your HEAD (git reset) to the desired reference point.

Using the IntelliJ VCS utilities, do as follows:

  1. Checkout the relevant branch git checkout my-branch

  2. In the git operations menu, select Reset HEAD...
    intellij git menu

  3. In the "Reset Head" dialog, select the Reset type as "hard" and enter the reference you want to revert back to. You can use almost any valid reference (as accepted by git reset), like a commit SHA, a relative reference (like HEAD~10). reset head dialog

  1. Optionally validate the change using the validate button, then click "Reset"

This would be the equivalent of the git reset operation:

REF="abc123"
git reset --hard "$REF"

Git reset is a local operation and won't impact anything on the remote unless you push your local changes.

  • Related