Avoid the DCO error for your pull requests in a GitHub repository fork

You may have encountered a situation where your fork from a GitHub project displayed the following error: ‘DCO is missing.’ Developer Certificate of Origin (DCO).

You can find instructions on how to fix the problem in the GitHub documentation. You can follow these steps when you fork and clone a repository directly to your local machine from the beginning.

  • Execute the following command

git commit –amend –no-edit –signoff

  • Add a .git/hooks/commit-msg file with the following content to your locally cloned project.
#!/bin/sh
#
# An example hook script to check the commit log message.
# Called by "git commit" with one argument, the name of the file
# that has the commit message. The hook should exit with non-zero
# status after issuing an appropriate message if it wants to stop the
# commit. The hook is allowed to edit the commit message file.
#
# To enable this hook, rename this file to "commit-msg".

# Uncomment the below to add a Signed-off-by line to the message.
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
# Hook is more suited to it.
#
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"

# This example catches duplicate Signed-off-by lines.

SIGNATURE="Signed-off-by: `git config --global --get user.name` <`git config --global --get user.email`>"
grep -qs "^${SIGNATURE}" "$1" || echo "\n${SIGNATURE}" >> "$1"

With these steps, you can can avoid the DCO error and ensure your pull request works seamlessly. It’s that straightforward and it works.

The image below shows the working pull request.

That’s all ;-).


I hope this was useful to you and let’s see what’s next?

Greetings,

Thomas

#dco, #github, #pullrequest

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Blog at WordPress.com.

Up ↑