gordyt / git-util

various notes and scripts for working with git

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

git-util

The purpose of this repository is to provide information and tools for working with git.

bin

analyze-repo

This is a bash script that will identify the largest files in a local git repo. Credits:

clone-and-filter-repo

This has been rewritten in Python for better performance and also to make it more flexible. It can now handle creating a new component-focused repository that is based off of one or more top-level directories, typically based off one of the following:

  • zcs-full
  • zd-full
  • zqa-full

This script maintains full history, including branch labels. Run the script with -h or --help option for instructions. There are probably three typical patterns where this script can help. These are listed in order from fastest to slowest execution time.

  1. You just need to extract one subtree out of the source repo, with full history. You would use the following arguments: -s SRC-REPO -d DEST-REP -f FILTER-DIR
  2. You want to extract one subtree out of the source repo, and then further filter out parts of that subtree that are not required. You would use the following arguments: -s SRC-REPO -d DEST-REP -f FILTER-DIR -i INCLUDE-PATHS-FILE
  3. You want to extract multiple subtrees out of the source repo, and further filter out parts of the subtree that are not required. You would use the following arguments: -s SRC-REPO -d DEST-REP -f INCLUDE-PATHS-FILE

The crucial difference to keep in mind between action #2 and action #3 is the format of the INCLUDE-PATHS-FILE. The process of extracting a subtree first (as in action #2) promotes all of the children of FILTER-DIR to the top-level of DEST-REPO. But in action #3, because we do not first apply a subtree filter (you can only do that with one subtree), then the new contents of DEST-REPO maintain their full hierarchy.

Examples will follow.

  • .gitconfig - This is a sample Git configuration file.
    • To install it, just copy this file to $HOME/.gitconfig.
    • After doing so be sure to edit the file and add your actual name and email address.
    • Look in particular at the [alias] section.
    • To use any of the aliases, just enter git <alias> from the command-line; e.g., git lola.

release-tool

Python script for release owner/captain/manager to help with git tasks. Requires stashy

docs

  • basic-workflow - Walkthrough of all of the steps that may be required for working with git, starting with forking a repo and going all the way through issuing a pull request and (correctly) merging changes.
  • creating-stash-repo - instructions for creating a new repository in stash.
  • creating-ram-disk - basic instructions for creating a RAM disk as a working area for reposity operations. This is especially handy if you are performing your work from a system that has conventional drives but plenty of RAM.
  • getting-started - Setting up your local git environment
  • git-flow getting started - Getting started with git-flow.
  • import-pull-request-branch - Tutorial walkthrough that shows how to bring all of the commits from a pull request (from someone's fork) into a new bugfix or feature branch.
  • managing-build-dependencies - guidelines for managing build dependencies in the new git component-focused repositories
  • rearranging-commits - how to fix commit histories, in painful detail
  • stash-repos - the list of master repositories in stash from which all of the component-focused repositories are based.
  • walkthrough-full-history - a walkthrough of the process required to create a component-focused repository with full history, including branch labels. This document shows how to do everything "by hand," without the assistance of the clone-and-filter-repo script.
  • walkthrough-multiple-folders - a walkthrough of the entire process for creating a component-focused repo based off of multiple top-level source directories.
  • walkthrough-multiple-split - a different method for creating a new repo based off of multiple top-level source directories.
  • walkthrough-shrink-repo - Walkdown of steps taking to trim unnecessary files from a git repository.

additional notes about filtering repositories

  1. Some of the operations described in the procedures below can take a very long time to run. If you have available RAM on your machine, creating a RAM disk upon which to store your output repositories temporarily can help.
  2. If the list of files and directories to filter out of the new repository is excessively long, then the --tree-filter operation can take a really long time. In those cases it may be better to broaden the list of files/folders to include and then manually delete the extra ones that remain in the output repo after the operation has completed. When I tested with the zm-timezones repository, there sere 814 paths that had to be (potentially) removed from every commit in the output repo.
  3. If you do not require full history with branch labels in the new repo, then when you create your local clone repository (as the source), do not pull in every branch from stash, just the current main branch (or branches) that you need.

presentations

hands-on tutorials

Tutorials will be maintained in separate repositories as they may depend on having a specific organization of branches, etc., to facilitate proper execution of the tutorial.

rebase-merge-feature

This tutorial will walk you through the essential actions needed to manipulate the structure of your git repository. This will be especially important as teams transition to following recommended git best practices.

Start by cloning the tutorial to your local drive, then following the instructions in the README.

git clone git@gitlab.com:gordyt/rebase-merge-feature.git

Or, if you don't have credentials registered with GitLab

git clone https://gitlab.com/gordyt/rebase-merge-feature.git

Then prepare the repo by pulling down all of the remote branches:

cd rebase-merge-feature
for b in $(git branch --remotes --no-color | grep --invert-match 'master'); do git checkout -f --track "$b"; done
git checkout master

About

various notes and scripts for working with git


Languages

Language:Python 76.2%Language:Shell 17.6%Language:HTML 4.8%Language:Perl 1.4%