Git Catchup Changes

There are following ways to catch up/revert changes in GIT

Catchup changes from remote

  1. Pull out from remote again and you lost all of your local changes as well as hisory

    rm -Rf working_folders
    git clone remote_git_address
    
  2. Merge from remote and this keeps all your local changes

    git pull 
    

    or

    git fetch
    git merge
    


Catchup changes from local commit

  1. Roll back all files to the latest commit and you lost all of your local changes not submitted

    git reset --head HEAD
    
  2. Roll back specific files to the latest commit and you keep all of other local changes not submitted

    git checkout HEAD specific_file_name 
    
  3. Roll back all files to the latest commit and you lost all of your local changes not submitted. Hoever, this will submit a new commit as revert

    git revert HEAD
    

Note:

  • Git fast forward: It means code commit submmited should be ordered by time. To resolve the “non-fast-forward” error, you can use command 2 or 3. git -f push is not recommended since it forces push to remote.