
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
A command-line tool for social coding
Add co-authors to commits when you collaborate on code. Use when pairing with a buddy or mobbing with your team.
git-mob is a CLI tool, so you'll need to install the package globally.
npm i -g git-mob
MacOS use Homebrew
brew install git-mob
By default git-mob will use the global config .gitmessage
template to append co-authors.
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 co-authors git-mob uses a JSON file called .git-coauthors
, and will try to find it in the following directories:
GITMOB_COAUTHORS_PATH
environment variable is set this will override any other settings..git-coauthors
file in the root directory.~/.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. Also see add co-author command.
$ 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
$ 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>
Selected co-authors are stored globally meaning when switching between projects your co-authors stay the same*.
*Note: If you've set a local commit template in your config then that template will be updated. However, not when you switch projects and you will see a warning. You can run git mob
to update the commit template. Read more here
Provide the GitHub username to generate their co-author details. The anonymous GitHub email is used. You need to enable it see config.
$ git mob rkotze
Jane Doe <jane@example.com>
Richard Kotze <10422117+rkotze@users.noreply.github.com>
git commit -m
setupHow to append co-authors to the message when using message flag - git commit -m "commit message"
?
prepare-commit-msg
hook file in .git/hooks
dir. See hook-exampleschmod +x prepare-commit-msg
prepare-commit-msg
will need a script to read the co-authors, which can be done via git mob-print
. See hook-examples folder for working scripts.
The command git mob-print
will output to stdout
the formatted co-authors.
Note: > v1.1.0
git mob --installTemplate
and git mob --uninstallTemplate
has been removed.
You can install the git hook using [pre-commit](https://pre-commit.com/)
. Add the following to your pre-commit-config.yaml
repos:
- repo: https://github.com/rkotze/git-mob
rev: { tag-version }
hooks:
- id: add-coauthors
stages: ['prepare-commit-msg']
And install with: pre-commit install --hook-type prepare-commit-msg
.
Removing the above snippet and running git commit
will uninstall the pre-commit hook
prepare-commit-msg
fileGit Mob config is a section in the Git config.
If you are using a local commit template and want to remove the warning message then set this option to true
. Only reads from the local git config.
type: Boolean
, scope: local
, version: 2.2.0
git config --local git-mob-config.use-local-template true
To fetch authors from GitHub you need to enable it using the config.
type: Boolean
, scope: global
, version: 2.3.3
git config --global git-mob-config.github-fetch true
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 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 a new co-author to your .git-coauthors
file.
$ git add-coauthor bb "Barry Butterworth" barry@butterworth.org
Suggest co-authors from contributors in local Git repository and add to .git-coauthors
file.
Optional author filter by name or email.
$ git suggest-coauthors [author name | author email]
Print out path to .git-coauthors
file.
git mob -p
Open co-author file: git mob -p | xargs code
Find out more.
git mob -h
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) -> "
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
Read our blog post to find out why git-mob exists: Co-author commits with Git Mob
* If you have git-duet installed, you'll need to uninstall it since it conflicts with the git-solo command.
FAQs
CLI tool for adding co-authors to commits.
The npm package git-mob receives a total of 174 weekly downloads. As such, git-mob popularity was classified as not popular.
We found that git-mob demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.