{"id":32136772,"url":"https://github.com/mestrelion/git-tools","last_synced_at":"2025-10-21T04:10:51.197Z","repository":{"id":3035827,"uuid":"4056361","full_name":"MestreLion/git-tools","owner":"MestreLion","description":"Assorted git tools, including git-restore-mtime","archived":false,"fork":false,"pushed_at":"2025-08-29T20:36:22.000Z","size":207,"stargazers_count":323,"open_issues_count":12,"forks_count":80,"subscribers_count":14,"default_branch":"main","last_synced_at":"2025-10-02T01:31:18.236Z","etag":null,"topics":["git"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MestreLion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-04-17T19:32:21.000Z","updated_at":"2025-08-29T20:34:52.000Z","dependencies_parsed_at":"2023-12-25T04:26:33.259Z","dependency_job_id":"6aa9faea-566a-4abb-8a90-e22c7258a5b3","html_url":"https://github.com/MestreLion/git-tools","commit_stats":{"total_commits":190,"total_committers":16,"mean_commits":11.875,"dds":"0.17894736842105263","last_synced_commit":"a42a069bc755f0fa81316965335cb33dbf22a968"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/MestreLion/git-tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MestreLion%2Fgit-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MestreLion%2Fgit-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MestreLion%2Fgit-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MestreLion%2Fgit-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MestreLion","download_url":"https://codeload.github.com/MestreLion/git-tools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MestreLion%2Fgit-tools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280201379,"owners_count":26289592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-21T02:00:06.614Z","response_time":58,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["git"],"created_at":"2025-10-21T04:10:48.958Z","updated_at":"2025-10-21T04:10:51.183Z","avatar_url":"https://github.com/MestreLion.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"Git Tools\n=========\n\nAssorted git-related scripts and tools\n\n\nRequirements\n------------\n\n- **Git** (duh!). Tested in v2.17.1 and prior versions since 2010\n- **Python** (for `git-restore-mtime`). Requires Python 3.8 or later\n- **Bash** (for all other tools). Tested in Bash 4, some may work in Bash 3 or even `sh`\n\nBash and Python are already installed by default in virtually all GNU/Linux distros.\nAnd you probably already have Git if you are interested in these tools.\nIf needed, the command to install dependencies for Debian-like distros (like Ubuntu/Mint) is:\n\n\tsudo apt install bash python3 git\n\nInstallation\n------------\n\nFor [Debian](https://tracker.debian.org/pkg/git-mestrelion-tools),\n[Ubuntu](https://launchpad.net/ubuntu/+source/git-mestrelion-tools),\nLinuxMint, and their derivatives, in official repositories as `git-restore-mtime`:\n\n\tsudo apt install git-restore-mtime\n\nFor [Fedora](https://src.fedoraproject.org/rpms/git-tools)\nand in EPEL repository for CentOS, Red Hat Enterprise Linux (RHEL), Oracle Linux and others, as root:\n\n\tdnf install git-tools  # 'yum' if using older CentOS/RHEL releases\n\n[Gentoo](https://packages.gentoo.org/packages/dev-vcs/git-tools) and Funtoo, also as root:\n\n\temerge dev-vcs/git-tools\n\nArch Linux [AUR](https://aur.archlinux.org/packages/git-tools-git):\n\nFollow the [AUR instructions](https://wiki.archlinux.org/title/Arch_User_Repository#Installing_and_upgrading_packages) to build and install a package from the user contributed PKGBUILD or use your favorite AUR helper. Note this is a recipie for a VCS package that installs the latest Git HEAD as of the time you build the package, not the latest stable taggged version.\n\n[Homebrew](https://formulae.brew.sh/formula/git-tools):\n\n\tbrew install git-tools\n\n[MacPorts](https://ports.macports.org/port/git-tools/details/):\n\n\tsudo port install git-tools\n\nAlso available in Kali Linux, MidnightBDS _mports_, Mageia, and possibly other distributions.\n\n[GitHub Actions](https://github.com/marketplace/actions/git-restore-mtime): _(`git-restore-mtime` only)_\n```yaml\nbuild:\n  steps:\n  - uses: actions/checkout@v3\n    with:\n      fetch-depth: 0\n  - uses: chetan/git-restore-mtime-action@v2\n```\n\n**Manual install**: to run from the repository tree, just clone and add the installation directory to your `$PATH`:\n```sh\ncd ~/some/dir\ngit clone https://github.com/MestreLion/git-tools.git\necho 'PATH=$PATH:~/some/dir/git-tools' \u003e\u003e ~/.profile  # or ~/.bashrc\n```\n\nTo install the `man` pages, simply copy (or symlink) the files from [`man1/`](man1) folder\nto `~/.local/share/man/man1`, creating the directory if necessary:\n```sh\ndest=${XDG_DATA_HOME:$HOME/.local/share}/man/man1\nmkdir -p -- \"$dest\"\ncp -t \"$dest\" -- ~/some/dir/git-tools/man1/*.1  # or `ln -s -t ...`\n```\n\n\nUsage\n-----\n\nIf you installed using your operating system package manager, or if you added the cloned repository to your `$PATH`,\nyou can simply run the tools as if they were regular `git` subcommands! For example:\n\n\tgit restore-mtime --test\n\nThe magic? Git considers any executable named `git-*` in either `/usr/lib/git-core` or in `$PATH` to be a subcommand!\nIt also integrates with `man`, triggering the manual pages if they're installed,\nsuch as when installing using your package manager:\n\n\tgit restore-mtime --help\n\tgit help strip-merge\n\nIn case the manual pages are not installed in the system, such as when running from the cloned repository,\nyou can still read the built-in help by directly invoking the tool:\n\n\tgit-clone-subset --help\n\n\nUninstall\n---------\n\nFor the packaged versions, use your repository tools such as `apt`, `brew`, `emerge`, or `yum`.\n\nFor manual installations, delete the directory, manpages, and remove it from your `$PATH`.\n```sh\nrm -rf ~/some/dir/git-tools  # and optionally ~/.local/share/man/man1/git-*.1\nsed -i '/git-tools/d' ~/.profile\n```\n---\n\nTools\n=====\n\nThis is a brief description of the tools. For more detailed instructions, see `--help` of each tool.\n\ngit-branches-rename\n-------------------\n\n*Batch renames branches with a matching prefix to another prefix*\n\nExamples:\n\n```console\n$ git-rename-branches bug bugfix\nbug/128  -\u003e bugfix/128\nbug_test -\u003e bugfix_test\n\n$ git-rename-branches ma backup/ma\nmaster -\u003e backup/master\nmain   -\u003e backup/main\n```\n\ngit-clone-subset\n----------------\n\n*Clones a subset of a git repository*\n\nUses `git clone` and `git filter-branch` to remove from the clone all but the requested files,\nalong with their associated commit history.\n\nClones a `repository` into a `destination` directory and runs\n`git filter-branch --prune-empty --tree-filter 'git rm ...' -- --all`\non the clone to prune from history all files except the ones matching a `pattern`,\neffectively creating a clone with a subset of files (and history) of the original repository.\n\nUseful for creating a new repository out of a set of files from another repository,\nmigrating (only) their associated history.\nVery similar to what `git filter-branch --subdirectory-filter` does,\nbut for a file pattern instead of just a single directory.\n\n\ngit-find-uncommitted-repos\n--------------------------\n\n*Recursively list repos with uncommitted changes*\n\nRecursively finds all git repositories in the given directory(es), runs `git status` on them,\nand prints the location of repositories with uncommitted changes. The tool I definitely use the most.\n\n\ngit-rebase-theirs\n-----------------\n\n*Resolve rebase conflicts and failed cherry-picks by favoring 'theirs' version*\n\nWhen using `git rebase`, conflicts are usually wanted to be resolved by favoring the `working branch` version\n(the branch being rebased, *'theirs'* side in a rebase), instead of the `upstream` version\n(the base branch, *'ours'* side). But `git rebase --strategy -X theirs` is only available from git 1.7.3.\nFor older versions, `git-rebase-theirs` is the solution.\nDespite the name, it's also useful for fixing failed cherry-picks.\n\n\ngit-restore-mtime\n-----------------\n\n*Restore original modification time of files based on the date of the most recent commit that modified them*\n\nProbably the most popular and useful tool, and the reason this repository was packaged into distros.\n\nGit, unlike other version control systems, does not preserve the original timestamp of committed files.\nWhenever repositories are cloned, or branches/files are checked out, file timestamps are reset to the current date.\nWhile this behavior has its justifications (notably when using `make` to compile software),\nsometimes it is desirable to restore the original modification date of a file\n(for example, when generating release tarballs).\nAs git does not provide any way to do that, `git-restore-mtime` tries to work around this limitation.\n\nFor more information and background, see http://stackoverflow.com/a/13284229/624066\n\nFor TravisCI users, simply add this setting to `.travis.yml` so it clones the full repository history:\n```yaml\ngit:\n  depth: false\n```\n\nSimilarly, when using GitHub Actions, make sure to include `fetch-depth: 0` in your checkout workflow,\nas described in its [documentation](https://github.com/actions/checkout#Fetch-all-history-for-all-tags-and-branches):\n```yaml\n- uses: actions/checkout@v2\n  with:\n    fetch-depth: 0\n```\n\n\ngit-strip-merge\n---------------\n\n*A `git-merge` wrapper that delete files on a \"foreign\" branch before merging*\n\nAnswer for \"*How to set up a git driver to ignore a folder on merge?*\", see http://stackoverflow.com/questions/3111515\n\nExample:\n```console\n$ git checkout master\n$ git-strip-merge design photoshop/*.psd\n```\n---\n\nContributing\n------------\n\nPatches are welcome! Fork, hack, request pull!\n\nIf you find a bug or have any enhancement request, please open a\n[new issue](https://github.com/MestreLion/git-tools/issues/new)\n\n\nAuthor\n------\n\nRodrigo Silva (MestreLion) \u003clinux@rodrigosilva.com\u003e\n\nLicense and Copyright\n---------------------\n```\nCopyright (C) 2012 Rodrigo Silva (MestreLion) \u003clinux@rodrigosilva.com\u003e.\nLicense GPLv3+: GNU GPL version 3 or later \u003chttp://gnu.org/licenses/gpl.html\u003e.\nThis is free software: you are free to change and redistribute it.\nThere is NO WARRANTY, to the extent permitted by law.\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmestrelion%2Fgit-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmestrelion%2Fgit-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmestrelion%2Fgit-tools/lists"}