ManthanHD

Findings, thoughts and observations from the eye of a Software Engineer.

  • Findings
  • Agile
  • Thoughts
  • Educational
  • Skills
  • Random

linux

How to retroactively sign all commits in a branch

18th June 2021 / Leave a Comment

If you haven’t set up GPG signing, check out my previous post on this here.

Say you created a new branch from main called my-branch. This guide will help you to sign all of the commits that are in my-branch that are not in main.

For starters, do a git fetch origin so that we are up to date with remotes. Be on my-branch. Ensure that you are rebased correctly from the main branch. This is not so important but will keep things clean and make it easy to merge later.

git rebase origin/main

Resolve conflicts, if any. Ensure clean state. Now to retroactively sign commits on my-branch, run:

git rebase --exec 'git commit --amend --no-edit -n -S' -i origin/main

Being on my-branch basically what you are saying here is that:

  1. Start an interactive rebase from the last known commit that is on origin/main, rolling back temporarily.
  2. For every commit, execute (--exec) git commit command, amending each commit without modifying its contents and signing every commit

Hope this helps.

Did you find this post useful? Spread the word!

  • Facebook
  • Twitter
  • LinkedIn
  • Reddit
  • WhatsApp
  • More
  • Email
  • Skype

Like this:

Like Loading...
Posted in: Findings Tagged: git, linux, macos

Bulk edit filenames using shell

8th August 2018 / Leave a Comment