progit / progit2

Pro Git 2nd Edition

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Section describing setup for multiple "workspaces" using `includeIf`

elsiehupp opened this issue · comments

General overview of your idea

The book could add a section discussing how to set up multiple local "workspaces"—i.e. multiple sets of multiple cloned repositories—for the purpose of separating, say, work projects from personal ones.

I recently discussed my own approach to this scenario in the Git mailing list here, and the issue I had seemed more to do with documentation and discoverability than with Git itself.

The new section could discuss the [includeIf] directive, which otherwise does not appear in the Git Configuration section of the book.

For example, the section could propose the following:

[includeIf "hasconfig:remote.*.url:https://git.cs.example.edu/**"] path = .gitconfig_school

with ~/.gitconfig_school containing:

[user]
	name = "Alice J. Legalname"
	email = "a.legalname@example.edu"

or:

[includeIf "gitdir:github/"] path = ~/Repositories/github/.gitconfig

with ~/Repositories/github/.gitconfig containing:

[user]
	name = "Nick Notmy Legalname"
	email = "3434820+nicknotmylegalname@users.noreply.github.com"

As there are multiple ways of approaching the issue, the book section could decribe a handful of options.

What problem will this solve?

Many Git users have distinct sets of cloned repositories, e.g. "work", "personal" and/or "school", perhaps organized like:

  • ~/Repositories/work/cloned-repository-name
  • ~/Repositories/personal/other-cloned-repository-name

Each set may be defined by a common factor such as the following:

  • "hasconfig:remote.*.url:https://git.cs.example.edu/**"
  • "gitdir:example_corp/"

As each of these sets may have a different signing identity, it may become tedious setting it up for every single cloned repository.

Other repetitive setup tasks may apply for a given user, but signing identities are the first that comes to mind.

In the above-linked email thread, @PhilipOakley mentioned a recent discussion on the subject over in the git-for-windows discussion board, with additional considerations around Windows (as opposed to Unix) shells.

Have you thought about other solutions?

Yes. The issue here is that the highly ranked web search results for, e.g., git config --global do not talk about includeIf, and some of the web-based manpage mirrors[1][2] for man git-config are missing it entirely. Discussion of includeIf does not appear at all in the current edition of the Git Book, with discoverability of the feature limited to the following:

Many, many configuration options are supported, but a large fraction of them are useful only in certain edge cases; we’ll cover just the most common and useful options here. If you want to see a list of all the options your version of Git recognizes, you can run:

$ man git-config

This command lists all the available options in quite a bit of detail. You can also find this reference material at https://git-scm.com/docs/git-config.

Do you want to help with this enhancement idea?

Yes

Personally I might want to open a pull request with more specific information like what I included in this issue, but I probably won't get around to it for a little bit.