Cherry-picking certain commits into a branch
git checkout release-branch
git cherry-pick xyzabc123
git push origin release-branch
Undoing change from a merged PR from a branch
Checkout the branch where the PR was merged and run the following command –
git revert -m 1 commit_id_of_merge_pr
git revert
makes new commits to remove old commits in a way while keeping the commit history. This is the recommended way to undo a commit. There is also another command called git reset
, but this doesn’t keep the history of your commits.
Undoing change to a particular commit
git revert --no-commit commit_sha..HEAD
Push reference of one branch to another
git push origin master:production
List commit logs with reference
git reflog
One Reply to “Helpful Git Commands”
Comments are closed.