A better way to clone, organize and manage multiple git repositories

git-get

build Go Report Card

git-get is a better way to clone, organize and manage multiple git repositories.

Description

git-get gives you two new git commands:

  • git get clones repositories into an automatically created directory tree based on repo's URL, owner and name (like golang's go get).
  • git list shows status of all your git repositories.

Example

Installation

Each release contains two binaries: git-get and git-list. When put on PATH, git automatically recognizes them as custom commands and allows to run them as git get or git list.

macOS

Use Homebrew:

brew install grdl/tap/git-get

Linux

Download and install .deb or .rpm file from the latest release.

Or install with Linuxbrew:

brew install grdl/tap/git-get

Windows

Grab the .zip file from the latest release and put the binaries on your PATH.

Usage

git get

git get <REPO> [flags]

Flags:
  -b, --branch              Branch (or tag) to checkout after cloning.
  -d, --dump                Path to a dump file listing repos to clone. Ignored when <REPO> argument is used.
  -h, --help                Print this help and exit.
  -t, --host                Host to use when <REPO> doesn't have a specified host. (default "github.com")
  -r, --root                Path to repos root where repositories are cloned. (default "~/repositories")
  -c, --scheme              Scheme to use when <REPO> doesn't have a specified scheme. (default "ssh")
  -s, --skip-host           Don't create a directory for host.
  -v, --version             Print version and exit.

The <REPO> argument can be any valid URL supported by git. It also accepts a short USER/REPO format. In that case git-get will automatically use the configured host (github.com by default).

For example, git get grdl/git-get will clone https://github.com/grdl/git-get.

git list

Usage:
  git list [flags]

Flags:
  -f, --fetch               First fetch from remotes before listing repositories.
  -h, --help                Print this help and exit.
  -o, --out                 Output format. Allowed values: [dump, flat, tree]. (default "tree")
  -r, --root                Path to repos root where repositories are cloned. (default "~/repositories")
  -v, --version             Print version and exit.

git list provides different ways to view the list of the repositories and their statuses.

  • tree (default) - repos printed as a directory tree.

output_tree

  • flat - each repo (and each branch) on a new line with full path to the repo.

output_flat

  • dump - each repo URL with its current branch on a new line. To be consumed by git get --dump command.

output_dump

Dump file

git get is dotfiles friendly. When run with --dump flag, it accepts a file with a list of repositories and clones all of them.

Dump file format is simply:

  • Each repo URL on a separate line.
  • Each URL can have a space-separated suffix with a branch or tag name to check out after cloning. Without that suffix, repository HEAD is cloned (usually it's master).

Example dump file content:

https://github.com/grdl/git-get v1.0.0
[email protected]:grdl/another-repository.git

You can generate a dump file with all your currently cloned repos by running:

git list --out dump > repos.dump

Configuration

Each configuration flag listed in the Usage section can be also specified using environment variables or your global .gitconfig file.

The order of precedence for configuration is as follows:

  • command line flag (have the highest precedence)
  • environment variable
  • .gitconfig entry
  • default value

Env variables

Use the GITGET_ prefix and the uppercase flag name to set the configuration using env variables. For example, to use a different repos root path run:

export GITGET_ROOT=/path/to/my/repos

.gitconfig file

You can define a [gitget] section inside your global .gitconfig file and set the configuration flags there. A recommended pattern is to set root and host variables there if you don't want to use the defaults.

If all of your repos come from the same host and you find creating directory for it redundant, you can use the skip-host flag to skip creating it.

Here's an example of a working snippet from .gitconfig file:

[gitget]
    root = /path/to/my/repos
    host = gitlab.com
    skip-host = true

Contributing

Pull requests are welcome. The project is still very much work in progress. Here's some of the missing features planned to be fixed soon:

  • improvements to the git list output (feedback appreciated)
  • info about stashes and submodules
  • better recognition of different repo states: conflict, merging, rebasing, cherry picking etc.
  • plenty of bugfixes and missing tests

Acknowledgments

Inspired by:

Owner
Comments
  • Do not traverse through git repositories

    Do not traverse through git repositories

    This makes git list a lot faster (10 minutes to under 2 minutes in one test) and displays more useful information (at least to me).

    Example of git list from before this change demonstrating that git list was hiding the information about the main repository in favour of showing information about a composer dependency:

    ├── iguana-extras
    │   └── vendor
    │       └── dxw
    │           └── iguana HEAD ok
    │                      master ok
    

    Example from after this change:

    ├── iguana-extras master  [ 1 untracked ]
    │                 feature/readme no upstream
    │                 feature/update-iguana no upstream
    │                 fix/php-cs-fixer no upstream
    
  • Add option to leave out hostname from path in git get

    Add option to leave out hostname from path in git get

    This is a great tool, thank you! I would suggest that sometimes the hostname is redundant in the tree structure, and it might be nice to have an option to ignore it. So instead you'd just have <root>/<user>/<repo> rather than <root>/<host>/<user>/<repo>

  • Bump Go version to 1.16

    Bump Go version to 1.16

    Hey there, I just got my M1 MacBook Air and wanted to use git-get and installed it using the instructions in its README. Unfortunately the binary that is being downloaded is compiled for x86_64 which when run prints the error message

    fatal: cannot exec 'git-get': Bad CPU type in executable
    

    That only happens if Rosetta 2 is not installed on the Mac. After installing Rosetta 2 it works in emulated mode.

    Since git-get is a Go program it can be compiled as a native binary for Apple Silicon.

    I saw that you use GoReleaser for builds and releases. GoReleaser v0.157.0 released on 2021-02-17 will build a fitting binary automatically as long as Go 1.16 is used. This should be enough to get git-get working on Apple Silicon.

    Would you mind rebuilding the project to upload a binary for others to use as well? :)

  • Unclear error message: directory doesn't exist or can't be accessed

    Unclear error message: directory doesn't exist or can't be accessed

    I ran git list with a non-existent repo directory and got an error, but it doesn't tell me which directory it tried to access.

    richard   master  …  github.com  grdl  git-get  rm -rf ~/repositories/
    
    richard   master  …  github.com  grdl  git-get  ./list 
    Error: directory doesn't exist or can't be accessed
    
  • git get leaves behind empty folders if it fails

    git get leaves behind empty folders if it fails

    I ran ./get github.com/grdl/git-get which failed because I forgot the https://, but it left behind a bunch of empty folders.

    richard   master  …  github.com  grdl  git-get  ./get github.com/grdl/git-get
    Cloning into '/home/richard/repositories/github.com/github.com/grdl/git-get'...
    remote: Not Found
    fatal: repository 'https://github.com/github.com/grdl/git-get/' not found
    Error: "git clone https://github.com/github.com/grdl/git-get /home/richard/repositories/github.com/github.com/grdl/git-get": exit status 128
    
    
     richard   master  …  github.com  grdl  git-get  tree ~/repositories
    /home/richard/repositories
    └── github.com
        └── github.com
            └── grdl
    
    3 directories, 0 files
    
    

    I think it'd be nice to delete those if the command fails. Maybe it could `git clone ... target/directory.tmpXXXX and then rename that after the command succeeds and delete it if the command fails.

  • Cleanup empty directories created by a failed git clone

    Cleanup empty directories created by a failed git clone

    Failed git clone deletes only a final directory of the repository it tried to clone. All the parent dirs that were created are not removed even if they are empty. This PR adds a cleanup function which removes empty parent directories of a repository that failed to be cloned.

  • Improve error messages

    Improve error messages

    This improves error handling by:

    • indicating that error happened when loading status of a repository
    • printing errors that happened at the bottom of the output
    • Fixing #10 by adding path to the error message
  • Improve packages structure

    Improve packages structure

    This improves the structure of the packages.

    • Status loader is moved inside git package and made a part of RepoFinder.
    • Test helpers and test repo generators also are moved inside the git package because they are only being used by that package.
  • Add --skip-host flag to get command

    Add --skip-host flag to get command

    When set, git-get won't create a directory for the repo host. So instead of <root>/<host>/<user>/<repo>, a repo will be cloned into <root>/<user>/<repo>. It's useful if all repos some from the same host and that additional folder feels redundant.

  • git-list crashes when running on repo without commits

    git-list crashes when running on repo without commits

    Steps to reproduce:

    ❯ mkdir new-repo
    ❯ cd new-repo
    ❯ git init
    ❯ git list -r .
    .
    └──  error
    
    Oops, errors happened when loading repository status:
    git rev-parse --symbolic-full-name --abbrev-ref HEAD failed on .: fatal: ambiguous argument 'HEAD': unknown revision or path not in the working tree.
    Use '--' to separate paths from revisions, like this:
    'git <command> [<revision>...] -- [<file>...]'
    
    git ls-remote --get-url failed on .: fatal: No remote configured to list refs from.
    
  • Consider building one binary instead of two

    Consider building one binary instead of two

    Right now git-get relases two binaries: git-get and git-list. Consider building only a single git-get binary and embed the list functionality into it (eg, git get list or git get --list).

    It was suggested by the creator of git-bug based on disuccions about his project on git mailing list (link to the thread).

    Releasing only a single binary would reduce the "namespace grabbing" and may make more sense semantically since git list refers to repos managed by git get anyway.

git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command
git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command

git-xargs is a command-line tool (CLI) for making updates across multiple GitHub repositories with a single command. You give git-xargs:

Feb 5, 2022
GitHub CLI extension to clone (or update) all repositories in an Organization, with the ability to filter via search queries.

gh-org-repo-sync GitHub CLI extension to clone all repositories in an Organization, with the ability to filter via search queries. If a local clone al

Nov 2, 2022
Command-line tool to organize large directories of media files recursively by date, detecting duplicates.

go-media-organizer Command-line tool written in Go to organise all media files in a directory recursively by date, detecting duplicates.

Jan 6, 2022
(Probably) The easiest way to clone your base Go project repository

GoStrap GoStrap probably will going to be the easiest way for you to create new Go project using your existing project template. This CLI actually onl

Mar 13, 2022
Query git repositories with SQL. Generate reports, perform status checks, analyze codebases. 🔍 📊
Query git repositories with SQL. Generate reports, perform status checks, analyze codebases. 🔍 📊

askgit is a command-line tool for running SQL queries on git repositories. It's meant for ad-hoc querying of git repositories on disk through a common interface (SQL), as an alternative to patching together various shell commands.

Jan 3, 2023
CLI tool for manipulating GitHub Labels across multiple repositories

takolabel Installation Mac $ brew install tommy6073/tap/takolabel Other platforms Download from Releases page in this repository. Usage Set variables

Nov 3, 2022
A dead simple cli utility to help you manage your git stash
A dead simple cli utility to help you manage your git stash

A dead simple cli utility to help you manage your git stash.

Aug 2, 2022
A CLI to replace your git commit command, so your git message can partially follow the Conventional Changelog ecosystem
A CLI to replace your git commit command, so your git message can partially follow the Conventional Changelog ecosystem

COMMIT CLI A CLI to replace your git commit command, so your git message can partially follow the Conventional Changelog ecosystem. And yes, it is bui

Feb 9, 2022
git-glimpse is a command-line tool that is aimed at generating a git prompt like the one from zsh-vcs-prompt.

Git GoGlimpse git-glimpse is a command-line tool that is aimed at generating a git prompt like the one from zsh-vcs-prompt. The particularity of this

Jan 27, 2022
Golang library with POSIX-compliant command-line UI (CLI) and Hierarchical-configuration. Better substitute for stdlib flag.
Golang library with POSIX-compliant command-line UI (CLI) and Hierarchical-configuration. Better substitute for stdlib flag.

cmdr cmdr is a POSIX-compliant, command-line UI (CLI) library in Golang. It is a getopt-like parser of command-line options, be compatible with the ge

Oct 28, 2022
Terminal based wordle clone. Uses the amazing charm.sh libraries to render and expose the game over SSH

Terminal based wordle clone. Uses the amazing charm.sh libraries to render and expose the game over SSH

Nov 17, 2022
Debug Dockerized Go applications better
Debug Dockerized Go applications better

A tool that makes debugging of Dockerized Go applications super easy by enabling Debugger and Hot-Reload features, seamlessly. Installing go get -u gi

Jan 4, 2023
Better sync package for Go.

synx Better sync package for Go. Rationale TODO. Note For better sync/atomic package see atomix. Features Simple API. Easy to integrate. Optimized for

Dec 16, 2022
Use Golang to achieve better console backend services

Use Golang to achieve better console backend services

Dec 7, 2021
A modern UNIX ed (line editor) clone written in Go

ed (the awesome UNIX line editor) ed is a clone of the UNIX command-line tool by the same name ed a line editor that was nortorious for being and most

May 29, 2021
😎 Yet Another yes clone but in Golang

Yeah Output a string repeatedly until killed. Yet Another yes clone but in Golang. Usage Just like yes: yeah This will print "y" until the process is

Apr 7, 2022
Spotify clone server for golang
Spotify clone server for golang

Spotify-clone-server Written by ?? rasulov-emirlan ?? sultanaliev-s ?? Howe to use this server ?? create repository called "database" right next to th

Aug 31, 2022
Grab is a tool that downloads source code repositories into a convenient directory layout created from the repo's URL's domain and path

Grab is a tool that downloads source code repositories into a convenient directory layout created from the repo's URL's domain and path. It supports Git, Mercurial (hg), Subversion, and Bazaar repositories.

Jun 2, 2022
ghcv-cli makes it easy to view the user-created issues, pull requests, and repositories in the terminal.
ghcv-cli makes it easy to view the user-created issues, pull requests, and repositories in the terminal.

ghcv-cli ghcv-cli makes it easy to view the user-created issues, pull requests, and repositories in the terminal. About Show a list of pull requests c

Mar 13, 2022