How to revert changes (safe way)
- run
git log --onelineundersml@norj:/sml/git/prod/
CommitId Commit_Msg
894a58a8 Merged PR 746: Only active and requested metas for each cell @OP10
81d3f285 Cell2 OP10 fid in fids.h
bd28eed8 Only active and requested metas for each cell @OP10
138a400f (tag: 20250120093138_cor, tag: 20250120093015_cor, tag: 20250120082547_cor, origin/TFS34540) Only meters v51 may pass G340, skip the rest.
36a3c5be Add CRC update after calibration for G190, add diag status and options
- find the latest stable version of the code. lets say in our case that is the commit
36a3c5be - run
git checkout 36a3c5beto point the HEAD to this version, instead of the master - if possible, fix your bugs and run
git checkout masterto return the HEAD point back to master
git revert vs git reset
git revert <insert bad commit hash here>
git revert creates a new commit with the changes that are rolled back.
git reset erases your Git history instead of making a new commit.
The git revert command reverts to a specified commit but keeps the history of every other commit made to the code base, and creates a new commit for the reverted changes. This is a more efficient way of undoing changes when collaborating with others.
Alternatively, the git reset command will revert back to a specified commit, then delete every commit that comes after the specified commit.
To be on the safe side, use git revert when undoing changes in a repo that has other developers working on it.
You can use git reset in cases where you want to completely get rid of commits after undoing changes.
git merge / git fetch / git pull
In the simplest terms, git pull does a git fetch followed by a git merge.
git fetch updates your remote-tracking branches under refs/remotes/<remote>/. This operation is safe to run at any time since it never changes any of your local branches under refs/heads.
git pull brings a local branch up-to-date with its remote version, while also updating your other remote-tracking branches.
From the Git documentation for git pull:
git pullrunsgit fetchwith the given parameters and then depending on configuration options or command line flags, will call eithergit rebaseorgit mergeto reconcile diverging branches.
![flow][static/images/git.png]