GitCid

pipeline status sponsor the project gitc.id“power tools for gitCopyright © 2021 Jeremy Carter <jeremy@jeremycarter.ca>


gitcid logo

Table of Contents


Links

Website

Source Code


Terms of Use

Use of this software is governed by the terms of the included MIT License (GitHub mirror).


Features


Dependencies

GitCid will try to install these for you automatically if they’re missing from your system, but if it fails, you might need to install them yourself:

There are a few more dependencies needed depending on your OS, but they should be installed automatically in most cases. See the files in .gc/.gc-deps for full details.


Quickstart


Download GitCid

  1. Make sure you’ve installed git and curl first, then run the following command:

    source <(curl -sL https://tinyurl.com/gitcid)

    When this command finishes, it will have created a new folder called gitcid in your current directory, and then it will bring you into this new folder.

  2. (Optional) Or if you prefer, you can run this command instead:

    git clone https://gitlab.com/defcronyke/gitcid.git && cd gitcid && echo "" && .gc/init.sh -h

Create a new git remote with GitCid features

  1. In the gitcid folder, run this command:

    .gc/new-remote.sh ~/repo1.git
  2. You can use remote ssh paths for the new remote repo location also, instead of a local path, for example:

    .gc/new-remote.sh git1:~/repo1.git
  3. An example git clone command to clone your git repo might look something like this:

    git clone git1:~/repo1.git && cd repo1

    It’s just the regular way of cloning git repos.

  4. When you make your new remote repo, you will also be given a command you can use to add GitCid features to your locally cloned repo that you cloned from the remote. Here’s that same command in case you need it. Make sure you’re inside your local repo when you run this command:

    source <(curl -sL https://tinyurl.com/gitcid) -e

    The above command will add GitCid to your git repo in a .gitignore’d folder called: .gc/


Usage Examples


Get Usage Help

Install GitCid into an existing git repo

Make new git repositories

  1. Make a new local git repo with the default name of “repo” in the current directory:

    .gc/init.sh
  2. Make a new local git repo:

    .gc/init.sh ./local-repo
  3. Make a new remote git repo at a target ssh server path:

    .gc/init.sh user@host:~/remote-repo
  4. Make several new git repos at once, local and/or remote ones:

    .gc/init.sh local-repo1 user@host:~/remote-repo1 user@host:~/remote-repo2 ./local-repo2
  5. Make several new bare git repos at once (suitable for using as git remotes), local and/or remote ones:

    .gc/init.sh -b user@host:~/remote-bare-repo1.git local-bare-repo1.git ./local-bare-repo2

Install a Dedicated Git Server


Install a git server at a target ssh location, using tools from this project:

https://gitlab.com/defcronyke/git-server

Currently supported target platforms:

Platform support wishlist (Please feel free to test and contribute fix suggestions if you’d like to help with adding support for these):

Maybe it works on other Debian or Debian-based platforms, but this hasn’t been tested yet.

WARNING: USE AT YOUR OWN RISK! You should only run the commands in this section to install a dedicated git server onto a freshly installed Linux distro which is intended to be used only as a dedicated git server! This will install some dependencies automatically and do some system configurations that you might not prefer to have on devices that are being used for other purposes. USE AT YOUR OWN RISK! YOU HAVE BEEN WARNED!!


TLDR; Let’s just install the git server


Git Server Install Instructions

  1. Install GitCid:

    source <(curl -sL https://tinyurl.com/gitcid)

    If successful, you will now be inside the freshly downloaded ./gitcid/ folder. You need to be inside this folder for step 2.

  2. Install new git server(s) onto dedicated device(s) at the given ssh target location(s):

    .gc/new-git-server.sh -h
    .gc/new-git-server.sh git1 git2 gitlab
    .gc/new-git-server.sh -o git1 git2 gitlab
    .gc/new-git-server.sh -y git1 git2 gitlab
    .gc/new-git-server.sh -yo git1 git2 gitlab
    .gc/new-git-server.sh -s git1 git2 gitlab
    .gc/new-git-server.sh -so git1 git2 gitlab
    .gc/new-git-server.sh -yo pi@git1 pi@git2 $USER@gitlab

    If everything worked as intended, your git server(s) are now ready to use. See the output in your terminal for more details. During parallel installs (the default behaviour unless using the -s flag variants), if non-interactive sudo support isn’t configured on the target, the system will fall back to sequential install mode for any targets which need the sudo password typed manually. After typing the sudo password once successfully, a passwordless sudo configuration will be attempted on the target, so that any future interactions with that target can be fully-automated.


Git Server Usage Examples

Here’s some examples of how to use your git server for some common git-related tasks. The following commands should be run from inside your gitcid/ folder, or inside any gitcid-enabled git repo.

  1. Create a new git remote repo on the git server, for example, a repo named repo1.git at the hostname git1:

    .gc/new-remote.sh git1:repo1

    Newly created remote repos will become available for use after a short delay, typically less than 1 minute. If you receive an error when trying to use a newly created remote repo, try again after 1 minute has passed since creating it and it should work.

  2. Clone a local copy of your new repo from the server:

    git clone git1:~/git/repo1.git
    cd repo1
  3. Commit some changes to your new repo, then push it to the origin remote on your git server:

    date | tee -a test1.txt
    git add .
    git commit -m "A test commit."
    git push
  4. (Optional) Add gitcid to your local copy of your git repo if you’d like to use any gitcid commands while working inside your repo. Run the following command while inside your repo to install gitcid features:

    source <(curl -sL https://tinyurl.com/gitcid) -e
  5. (Optional) With gitcid added to your repo from the previous step, you can commit and push more easily:

    .gc/commit-push.sh Commit message.

Git Server Development

If you’d like to contribute to the development of the git server, you can run this command if you want, to help you set up your dev environment for this purpose:

source <(curl -sL https://tinyurl.com/gitcid) -d

It will clone all related project git repositories, and it will install gitcid into them for convenience.