Code Monkey home page Code Monkey logo

subgit's Introduction

subgit

You have a git repository, and the files are ignored. But maybe those ignored files are really important, and you want to manage them with git?

subgit is a tool that helps you manage git repositories within a git repository. Not a submodule of git but a separate git repo that exists inside the current git repo. Completely separate, only sharing working directory.

Let's say your repo is like this:

project-x/
├── index.js
├── .env             <--- git ignored
└── .gitignore

Using subgit, you will create a bare git repo named subgit in the .git folder. You can use this repo to do anything, such as managing ignored files (.env, docs/, .dev/,...).

project-x/
├── .git/
│   └── subgit/
├── index.js
├── .env
└── .gitignore

.env file ignored by .gitignore in current git repo, but tracking by .git/subgit repo.

Install

Just download subgit file, then put somewhere you can access in terminal.

Example: store in $HOME/bin/ folder

wget https://raw.githubusercontent.com/madnh/subgit/master/subgit -O $HOME/bin/subgit

chmod +x $HOME/bin/subgit

Usage

subgit [command]

Avaiable commands:
  init              Initialize a subgit repo

  list              List all subgit repos. Alias: `ls`

  remove            Remove a subgit repo, before remove will show confirm, type 'yes' to remove. Alias: `rm`

  shell             Enter subshell of subgit, this subshell already define GIT_DIR and GIT_WORK_TREE.
                    You can run commands like `git status`, `git commit`, `lazygit`,.. etc.

  lazygit           run lazygit on subgit. This is a shortcut for `subgit shell` then run `lazygit`. Alias: `lazy`

  [git command]     Other commands of git, like: status, branch, checkout, reset, push,... etc

Environment variables

Name Desc
SUBGIT Name of subgit folder. If specified then target folder will be ".git/subgit-$SUBGIT", else ".git/subgit"
IS_SUBGIT_SUBSHELL subgit use this env to indicated that current shell is in a subgit repo

Examples

Create a subgit repo

subgit init

Create a subgit repo with custom name

SUBGIT=foo subgit init

List current subgit repos

subgit list

# or:
subgit ls

Remove a subgit repo

Remove default repo

subgit remove

Remove custom repo

SUBGIT=foo subgit remove

Open a subgit repo with Lazygit

subgit lazygit

# or
subgit lazy

# or
SUBGIT=foo subgit lazy

Open a subshell in context of subgit repo

subgit shell

# or
SUBGIT=foo subgit shell

Run git commands

subgit status
subgit add [file]
subgit add [file] --force
subgit commit
subgit push

# or
SUBGIT=foo git add status

subgit's People

Contributors

madnh avatar

Stargazers

 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.