Skip to content
A cross-platform command-line tool for social coding. Includes co-authors in commits when pair/mob programming.
JavaScript
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/ISSUE_TEMPLATE 📝 Add template for feature requests Jun 9, 2018
bin Upgrade deps to fix security alerts Jun 12, 2019
hook-examples
src Upgrade deps to fix security alerts Jun 12, 2019
test-helpers
.gitignore
.npmignore Exclude .prettierignore from bundled package May 12, 2018
.prettierignore Prettier ignore package.json May 10, 2018
.prettierrc
.travis.yml 👷 Symlink package in CI build Mar 31, 2018
CODE_OF_CONDUCT.md
CONTRIBUTING.md
README.md
package-lock.json 1.0.1 Aug 15, 2019
package.json 1.0.1 Aug 15, 2019

README.md

Git Mob npm downloads npm version build status

A command-line tool for social coding

Includes co-authors in commits when you collaborate on code. Use when pairing with a buddy or mobbing with your team.

Read our blog post to find out why git-mob exists: Co-author commits with Git Mob

New Git Mob VS Code extension

gif showing example usage of git-mob

  1. Install
  2. Prepare commit msg setup
  3. Workflow / Usage
  4. More commands
    1. List all co-authors
    2. Overwrite the main author
    3. Add co-author
    4. Delete co-author
    5. Edit co-author
    6. Add initials of current mob to PS1, in ~/.bashrc

Install

Warning: This package hasn't reached v1.0.0 yet. There may be many missing features, lots of bugs, and the API could change until we reach a stable version.

git-mob is a CLI tool, so you'll need to install the package globally.

npm i -g git-mob

By default git-mob will use the .gitmessage template to append co-authors.

Prepare commit msg setup

Do you want the co-authors appended to the message when using the command git commit -m "commit message"?

  1. git mob --installTemplate
  2. Add prepare-commit-msg to .git/hooks and see hook-examples

More details about above ^

--installTemplate This will create a file in your local .git folder where it will write the selected co-authors into.

prepare-commit-msg will need a script to read the co-authors template. See hook-examples folder for working scripts.

The command git mob-print will output to stdout the formatted co-authors which you can use in your own git hooks.

Revert back to default setup

  1. git mob --uninstallTemplate
  2. Remove prepare-commit-msg file

Workflow / Usage

With git-mob, the primary author will always be the primary user of the computer. Set your author info in git if you haven't done so before.

$ git config --global user.name "Jane Doe"
$ git config --global user.email "jane@example.com"

To keep track of potential co-authors, git-mob uses a JSON file called ~/.git-coauthors. Here's a template of its structure.

{
  "coauthors": {
    "<initials>": {
      "name": "<name>",
      "email": "<email>"
    }
  }
}

Start by adding a few co-authors that you work with.

$ cat <<-EOF > ~/.git-coauthors
{
  "coauthors": {
    "ad": {
      "name": "Amy Doe",
      "email": "amy@findmypast.com"
    },
    "bd": {
      "name": "Bob Doe",
      "email": "bob@findmypast.com"
    }
  }
}
EOF

You're ready to create your mob. Tell git-mob you're pairing with Amy by using her initials.

$ git mob ad
Jane Doe <jane@example.com>
Amy Doe <amy@example.com>

Commit like you normally would. You should see Co-authored-by: Amy Doe <amy@example.com> appear at the end of the commit message.

Let's add Bob to the group to create a three-person mob.

$ git mob ad bd
Jane Doe <jane@example.com>
Amy Doe <amy@example.com>
Bob Doe <bob@example.com>

Once you're done mobbing, switch back to developing solo.*

$ git solo
Jane Doe <jane@example.com>

More commands

List all co-authors

Check which co-authors you have available in your .git-coauthors file.

$ git mob --list
jd Jane Doe jane@example.com
ad Amy Doe amy@example.com
bd Bob Doe bob@example.com

Overwrite the main author

Overwrite the current author which could be useful for pairing on different machines

If the current author is: Bob Doe

$ git mob -o jd ad
jd Jane Doe jane@example.com
ad Amy Doe amy@example.com

Now the author has changed to Jane Doe.

Add co-author

Add a new co-author to your .git-coauthors file.

$ git add-coauthor bb "Barry Butterworth" barry@butterworth.org

Delete co-author

Delete a co-author from your .git-coauthors file.

$ git delete-coauthor bb

Edit co-author

Edit a co-author's details in your .git-coauthors file.

$ git edit-coauthor bb --name="Barry Butterworth" --email="barry@butterworth.org"
$ git edit-coauthor bb --name="Barry Butterworth"
$ git edit-coauthor bb --email="barry@butterworth.org"

Add initials of current mob to your prompt

Bash

Add the initials to PS1, in ~/.bashrc

function git_initials {
  local initials=$(git mob-print --initials)
  if [[ -n "${initials}" ]]; then
    echo " [${initials}]"
  fi
}

export PS1="\$(pwd)\$(git_initials) -> "

Fish

Add the following functions to .config/fish/config.fish

function git_initials --description 'Print the initials for who I am currently pairing with'
  set -lx initials (git mob-print --initials)
  if test -n "$initials"
    printf ' [%s]' $initials
  end
end

function fish_prompt
  printf "%s%s ->" (pwd) (git_initials)
end

* If you have git-duet installed, you'll need to uninstall it since it conflicts with the git-solo command.

Find out more with git mob -h

You can’t perform that action at this time.