git update-ref is a command that updates the value of a reference in the repository.
π‘ This is a low-level command that directly manipulates refs without creating reflog entries or performing safety checks. Itβs useful for scripting or creating custom references.
git update-ref refs/heads/current HEAD
This command updates the refs/heads/current reference to point to the current HEAD.
git update-ref refs/heads/previous HEAD~1
This command updates the refs/heads/previous reference to point to the previous commit.
The ref name can be used in a git checkout command to switch to that commit.
git checkout previous
git update-ref -d refs/heads/previous
π‘ Use the -d flag to delete a reference safely.
π Happy coding!