@spaceatmoon

Можно ли заставить git спрашивать под каким пользователем коммитить?

Собственно вопрос в заголовке. У меня для разных систем - Github, Gitlab и т.д. разные учётные записи, как рабочие, так и личные. Каждый раз контролировать для каждого репозитория какой установлен пользователь очень утомительно и всё равно случается ошибка. Коммиты бывают улетают с не теми настройками авторства.

Можно ли настроить как-то список пользователей и потом git бы спрашивал под каким пользователем фиксировать изменения?
  • Вопрос задан
  • 160 просмотров
Решения вопроса 1
firedragon
@firedragon
Не джун-мидл-сеньор, а трус-балбес-бывалый.
Git Configuration
As you read briefly in Getting Started, you can specify Git configuration settings with the git config command. One of the first things you did was set up your name and email address:

$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
Now you’ll learn a few of the more interesting options that you can set in this manner to customize your Git usage.

First, a quick review: Git uses a series of configuration files to determine non-default behavior that you may want. The first place Git looks for these values is in the system-wide [path]/etc/gitconfig file, which contains settings that are applied to every user on the system and all of their repositories. If you pass the option --system to git config, it reads and writes from this file specifically.

The next place Git looks is the ~/.gitconfig (or ~/.config/git/config) file, which is specific to each user. You can make Git read and write to this file by passing the --global option.

Finally, Git looks for configuration values in the configuration file in the Git directory (.git/config) of whatever repository you’re currently using. These values are specific to that single repository, and represent passing the --local option to git config. If you don’t specify which level you want to work with, this is the default.

Each of these “levels” (system, global, local) overwrites values in the previous level, so values in .git/config trump those in [path]/etc/gitconfig, for instance.
Ответ написан
Пригласить эксперта
Ответы на вопрос 1
У меня для разных систем - Github, Gitlab и т.д. разные учётные записи, как рабочие, так и личные.

Может не совсем то, что вы хотите, что в GitKraken есть функциональность профилей, решение как раз для вашего случая. Пользуюсь именно для этого - несколько "рабочих" учёток с корпоративной почтой в author/commit email, и личная. Переключаться нужно заранее, перед коммитом (просто обновляется глобальный .gitconfig).
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы