Category Archives: Git

Git: Add ‘Signed-Off-By’ From Command Line

In order to append a Signed-off-by line with the author’s information.

In order to automatically append this line to the commit, append a ‘-s’ switch to the git commit command:

$ git commit -s

Just be sure your name and email are correct in the appended line, and you are done!

NOTE: In case your information is not correct, issue:

$ git config --global "Your Name"
$ git config --global ""



Git: basic tag commands

To get the repository’s tags issue:

$ git fetch --tags [branch_name]

To add a tag to the top commit:

$ git tag -a

Note: this will open an editor screen where you can insert a description message (similar to a commit)

To add a tag to a specific commit:

$ git tag -a [tag_name] [commit_hash]

To push a tag to remote:

$ git push [repo_name] --tags  # for all tags
$ git push [repo_name] [tag_name] # for a single tag named 'tag_name'

To merge a tagged commit:

$ git merge [tag_name]

See also: how to see the information of the repo’s branches from the CLI, including your tags in this post


Git: add a remote repository

In case you need to work with more than one remote repositories, chances are you need to add one of them (origin comes as a default).

$ git remote add remote_name 

Choose the remote_name as you wish and grab the repo URL from github.

You may also be interested in Selecting remote repository on git or maybe if you need to rename your remote, you might want to read how to rename a remote repository

For a little more information, visit:


Git: Show history of a file

There are two main ways to show the history of a file using git (that is, listing all commits that changed a provided file).

The best one is:

$ git log --follow filename

It will list all commits that ever touched that file, including renames

$ git log -- path/to/file

…will also list all commits, but without resolving file renames.

You might also like git history log of a line, that lists all commits that ever touched a specific line


Change the author of a git commit

Issue this command to change the author of the very last commit message:

$ git commit --amend --author="John Doe <>"

To change the author of your config file:

$ git config --global "John Doe"
$ git config --global ""

For more commands, visit

For more git quick commands, go to


Create patches with git format-patch

Git has a wonderful tool that allows you to create patches of the commits in the tree of your project: git format-patch.


 $ git format-patch [<options>] [<since> | <revision-range>]

More information can be seen via man page:

$ git format-patch -h


$ man git format-patch

For example:

$ git format-patch -N

This command generates one .patch file for each of the N commits on the top of your tree. Example:

$ git format-patch -1

Generates a .patch file for the commit on the top of your tree. Increase the number to get one file per commit (for the top 3 commits, use ‘-3’).

To apply the patch, use

$ git am [your-patch].patch