fork-dev / Tracker

Bug and issue tracker for Fork for Mac
506 stars 12 forks source link

[Feature] set multiple .git_config files for multiple directories #2010

Open chobotoid opened 10 months ago

chobotoid commented 10 months ago

I'm not sure how this could work, but I've recently encountered a situation where I'd like to use multiple git config files - one for personal stuff, one for school, one for work e.g., and of course there's a way to set the repository config after cloning it, however what I'd like is to override the global git config based on the directory I'm in. E.g. I set it that I use username "school nick" and email "school@email.org" whenever I'm in directory ~/School or its subdirectories, that way I don't have to manually set up the local git config whenever I clone a repo into the ~/School or its subdirectories. If this could also work with different ssh keys (e.g. when I have both personal and school gitlab accounts and gitlab forbids to use the same ssh key in two accounts), that would be amazing.

I'm guessing this isn't really common issue and most people just gotten used to it, but if someone implemented this into the app, I'd be eternally grateful 😀 just to be able to set it up and forget about it and let it do its magic.

DanPristupov commented 10 months ago

https://stackoverflow.com/a/59184292

Search for git includeIf

chobotoid commented 10 months ago

I've done so and honestly tried to do this, but somehow I wasn't able to make it work, neither in terminal nor while using the app, I'll try to do it again though, thanks.

EDIT: I've tried to set it up again, but was unsuccessful, here's what I have in global git config:

[user]
        name = Chobotoid
        email = personal@email.com
[core]
    excludesfile = ~/.gitignore_global
[includeIf "gitdir:~/Documents/School/"]
    path = .gitconfig.school

then in .gitconfig.school I have:

[user]
    name = Full Name
    email = school@email.org

yet even when i go into ~/Documents/School/ or its subdirectories and write git config user.email in terminal, it gives personal@email.com as an answer and when I try to clone a repo into the directory through the fork app, by default it sets up the global git config as well, could you give me a hint as to what am I doing wrong?

Also I'm using the M1 MacBook and the "git version 2.39.3 (Apple Git-145)", if that makes difference, thanks for any help in advance.