Coder Social home page Coder Social logo

recursive-gitconfig's Introduction

recursive-gitconfig

recusrive-gitconfig is a Bash tool to support several .gitconfig within the same Linux session.

It can also be use to handle several dynamic Git identities.

Install

Copy the file recursive-gitconfig in your home folder and source it in your .bashrc.

cp recursive-gitconfig.sh ~/.recursive-gitconfig.sh
sed -i '1asource ~/.recursive-gitconfig.sh\n' ~/.bashrc

How it works

recursive-gitconfig.sh alias git command to look for the closest .gitconfig file in parents folders and use this one instead of the default ~/.gitconfig.

An example

Let's say your home directory is something like:

├── .gitconfig
├── personal
│   ├── .gitconfig
│   ├── project-one
│   ├── project-three
│   └── project-two
└── work
	├── client-project-one
	├── client-project-two
	└── .gitconfig

You basicaly have two main folders, personal and work and subfolders for each project.

Your main config file is ~/.gitconfig but you added two specifics files ~/work/.gitconfig and ~/personal/.gitconfig.

~/.gitconfig:

[user]
	email = [email protected]
	name = Arnout Pierre

[color]
	lol = log --graph --decorate --pretty=oneline --abbrev-commit
	lola = log --graph --decorate --pretty=oneline --abbrev-commit --all

~/work/.gitconfig:

[user]
	email = [email protected]
	name = Arnout Pierre (Company)
[include]
	path = /home/arount/.gitconfig

~/personal/.gitconfig:

[user]
	name = Arount
[include]
	path = /home/arount/.gitconfig

From here there are three specific identities possible to have on the same session,

  • Arnout Pierre / [email protected] is my default identity, the fallback and will be used everywhere except ~/work and ~/personal.
  • Arnout Pierre (Company) / [email protected] is my professional identity, only used under ~/work/.
  • Arount / [email protected] is my personal identity, for my personal projects, only used under ~/personal/.

Because both of my specific .gitconfig files include the default ~/.gitconfig I still access my alias from any identity.

Bugs

If you experience a bug, please check recursive-gitconfig.sh is sourced at the top of your .bashrc.

Otherwise feel free to submit an issue or PR.

recursive-gitconfig's People

Contributors

arount avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.