GithubHelp home page GithubHelp logo

wrbbz / git-workspace Goto Github PK

View Code? Open in Web Editor NEW

This project forked from orf/git-workspace

0.0 0.0 0.0 1.39 MB

Sync personal and work git repositories from multiple providers :rocket:

Home Page: https://github.com/orf/git-workspace

Rust 99.81% Shell 0.19%

git-workspace's Introduction

git-workspace ๐Ÿš€

Crates.io Actions Status

If your company has a large number of repositories and your work involves jumping between a lot of them then git-workspace can save you some time by:

  • Easily synchronizing your projects directory with Github, Gitlab.com or Gitlab self-hosted ๐Ÿ”ง
  • Keep projects consistently named and under the correct path ๐Ÿ“
  • Automatically set upstreams for forks โšก
  • Move deleted repositories to an archive directory ๐Ÿ’พ
  • Allowing you to access any repository instantly :shipit:
  • Execute git fetch on all projects in parallel :godmode:

This may sound useless, but the "log into your git provider, browse to the project, copy the clone URL, devise a suitable path to clone it" dance can be a big slowdown. The only obvious solution here is to spend more time than you'll ever spend doing this in your whole life on writing a tool in Rust to do it for you.

Table of Contents

Install ๐Ÿ’ฟ

Homebrew (MacOS + Linux)

brew tap orf/brew, then brew install git-workspace

Binaries (Windows)

Download the latest release from the github releases page. Extract it and move it to a directory on your PATH.

Cargo

Don't do this, it's pretty slow: cargo install git-workspace

Usage ๐ŸŽท

Git is really annoying and hijacks the --help flag for subcommands. So to get help use git-workspace --help, not git workspace --help.

Define your workspace

A workspace is the directory that git-workspace will manage for you, filling it with projects cloned from your providers. To configure this just set a GIT_WORKSPACE environment variable that points to an empty directory. For example:

export GIT_WORKSPACE=~/projects

Provider credentials

Both Github and Gitlab require personal access tokens to access their GraphQL endpoints. Create an access token here:

Export these tokens as GITHUB_TOKEN and GITLAB_TOKEN in your shell.

Adding providers

You can use git workspace add to quickly add entries to your workspace.toml:

  • Clone all github repositories for a user or org

    • git workspace add github [USER OR ORG NAME]
  • Clone a namespace or user from Gitlab:

    • git workspace add gitlab gitlab-ce/gitlab-services
  • Clone from a self-hosted gitlab instance:

    • git workspace add gitlab my-company-group --url=https://internal-gitlab.company.com

Multiple configs

Git workspace will read from any workspace*.toml file under your $GIT_WORKSPACE directory.

Updating your workspace

Running git workspace update will:

  1. Fetch all repositories from your providers
  2. Clone any new repositories that are not present locally
  3. Move any deleted repositories to $GIT_WORKSPACE/.archived/ for posterity

Fetching all changes

git workspace fetch will run git fetch on all projects.

Switch projects ๐Ÿ”

git workspace list will output the names of all your projects. You can integrate this with whatever tool you wish to provide a way to quickly search for and select repositories.

Fish, with fzf

The following fish shell snippet gives you a open-project [search-string] command you can use to search for and open projects. It combines the git workspace list command with fzf, and opens the project path with your $EDITOR:

# ~/.config/fish/functions/open-project.fish
function open-project -d "Open a project"
  set filter "$argv"
  set chosen_project (git workspace list | fzf -q "$filter")
  if string length -q -- $chosen_project
     $EDITOR $GIT_WORKSPACE/$chosen_project
     pushd $GIT_WORKSPACE/$chosen_project
  end
end

Bash, with fzf

Contributed by a user:

wsp() {
    if [[ "$#" == "0" ]]; then
        fzf_arg=""
    else
        fzf_arg="-q"
    fi
    cd ${GIT_WORKSPACE}/$(git workspace list | fzf $fzf_arg "$@")
}

Contributing ๐Ÿ›

This is my first 'proper' Rust project. If you're experienced with Rust you might puke at the code, but any feedback to help me improve would be greatly appreciated!

If you want to contribute then just go for it. cargo install should get you ready to go. Be warned: there are currently no tests ๐Ÿ’ฃ. I run integration tests with Github Actions, but that's about it. It's on my to-do list, I promise โ„ข๏ธ.

git-workspace's People

Contributors

dependabot-preview[bot] avatar orf 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.