13

I use git with a big development team and I'd like to have a set of aliases be common across every developer. They change every so often, so I'd like to store them in origin somehow. Is there any way to set that up in git? I'm using gitosis for the git server (not sure if that would make a difference).

jga
  • 139
  • 3

3 Answers3

11

1) Create .gitalias files with something like this:

[alias]
  # full status
  s = !git status -sb && git submodule foreach --recursive git status -sb

2) Commit this file.

3) Add following lines to .git/config:

[include]
    path = ../.gitalias

4) Ask all members of your team to repeat step 3.

tbraun89
  • 2,246
  • 3
  • 25
  • 44
Sergey Sha
  • 121
  • 1
  • 5
  • Tip: _automate_ part 4 by making it happen as a side-effect in a before- or after-hook of the build-tool _(npm, make, sbt, scons ... whatever)_ your project uses. – conny Oct 12 '20 at 04:23
1

You can versionning in your gitosis a default ~/.gitconfig with all of you alias and share configuration.

You can't modify you .git/config by project

You can too made some script to launch some git command like :


git config alias.st status
git config alias.ci commit

Each person to launch this script had this twice alias in local git config

shingara
  • 46,608
  • 11
  • 99
  • 105
1

Maintaining global .gitconfig separately as a git repository enables sharing aliases by multiple git repositories as well as across multiple workstation and users.

Please checkout answer here - https://stackoverflow.com/a/75145135/20597178

apero
  • 95
  • 7