git branch roll back to previous commits

I have got two branches (master and secondary) at most recent commit. I need the older commit ed state ( 2 unit backward) and so want my secondary branch to move back two commits.

How do I do it?

  • Git rollback 1 pull
  • What is the meaning of revert this commit and roll back this commit in GitHub for Windows?
  • How do I go back to an earlier commit of a file using git?
  • Git Deployment: How to rollback to previous stable version of my app?
  • How do I roll back all or part of a commit to svn?
  • Going back to a previous commit in Gitkraken
  • How do I rollback to a specific git commit
  • Git cannot undo modified files
  • One Solution collect form web for “git branch roll back to previous commits”

    git branch -f secondary secondary~2
    

    This will only change the commit which the branch references and does not interact with the worktree. as such it’s a bit safer than going the git reset route. It will not work if the branch is currently checked out, but this is easily solved by switching to another branch, creating a temporary branch, or detaching HEAD (git checkout HEAD^{}). Another possibility would be to use git checkout -B secondary secondary~2, but this will change your worktree.

    don’t do this, if your secondary branch was already pushed and was publicly available

    Git Baby is a git and github fan, let's start git clone.