0

In Git Extensions, I'd like to go back to an old version of all my files and folders in a repository, and check in all of them at once as the latest version of that branch. I have no pending untracked or non checked in changes. I'm not looking to 'revert' individual commits, or just to go back to an old version and look at it, or cherry pick individual commits, or make a new branch based on that older version. I basically want to do a bulk (in one shot) revert of all the commits since the revision I want to go back to. If I checkout that older version, then I cannot commit it because it shows nothing has changed relative to that revision. (I see that it is possible to do bulk reverts in Git command line.)

Chris
  • 1
  • 1
  • 2
    try reset, here is an example: https://stackoverflow.com/questions/1895059/revert-to-a-commit-by-a-sha-hash-in-git – user7396598 Mar 26 '18 at 17:25

2 Answers2

2

Git reset may help you, e.g.

git checkout <commit>
git reset --soft <branch>
git add -A
git commit

You will need to explicitly check out the branch again after this and do a (fast-forward) merge to the commit you created in the steps above.

RsrchBoy
  • 363
  • 1
  • 5
0

Suppose you are there :

--*--*--A--B--C--D <- branch
  • If you want to reset branch back to A, and just throw away B--C--D, use git reset --hard :

    # from branch :
    git reset --hard A
    
    # if you have a remote, you should 'push -f' to it :
    git push -f origin branch
    
    # the history will be reverted to :
    --*--*--A <- branch
    
  • If you want to keep B--C--D in your history, but set the content back to what was in A, you should :

    # from branch :
    # checkout the *content* of A (notice the '.') :
    git checkout A -- .
    
    # commit this as a new commit on top of D :
    git commit
    
    # the history will now be :
    --*--*--A--B--C--D--A' <- branch
    
LeGEC
  • 46,477
  • 5
  • 57
  • 104