Skip to content

Git: Build, deploy & roll back

Git commands for build, deploy & roll back (tags: #deploy #build #rollback #release #compose).

Index
3 items

Git: Revert a pushed commit safely

Safe

Creates a new commit that undoes the given one. Safe on shared branches.

git revert <commit-sha>
What each part does
  1. git revertmake a new commit that undoes the changes of an old one (history is not rewritten)
  2. <commit-sha>the commit to undo

Also known as: undo pushed commit · git revert

Git: Force push safely

Caution

Overwrite the remote branch only if nobody pushed since your last fetch.

git push --force-with-lease origin <branch>
What each part does
  1. git pushupload commits
  2. --force-with-leaseoverwrite the remote branch only if it is still where you last fetched it; fails if someone else pushed
  3. origin <branch>the remote and branch

Also known as: force push · push -f

Git: Create and push a release tag

Safe

Annotated tag for a release; pushing it usually triggers the release pipeline.

git tag -a <version> -m "<message>" && git push origin <version>
What each part does
  1. git tag -a <version>create an annotated tag (author, date, message), e.g. v1.4.0
  2. -m "<message>"the tag message
  3. &&push only if tagging worked
  4. git push origin <version>push that one tag (git push does not push tags by default)
Example
$ git tag -a v1.4.2 -m "Release 1.4.2" && git push origin v1.4.2

Also known as: tag release · semver tag

My DevOps Playbook by Angelo John Calleja

New runbook

GitHub not connected

Saving is handled by the site: the GitHub token is stored in Cloudflare, not in your browser. Enter the editor password (the EDITOR_PASSWORD secret) to unlock saving in this browser.

Saving commits to gelogrammer/My_DevOps_Playbook. Create a fine-grained token with access to only this repo andContents: Read and write, then paste it here. It is stored only in this browser.

src/content/docs/…