{"id":18021041,"url":"https://github.com/kevinjalbert/git_evolution","last_synced_at":"2026-05-02T19:32:19.934Z","repository":{"id":27566913,"uuid":"31049143","full_name":"kevinjalbert/git_evolution","owner":"kevinjalbert","description":"Gem that provides the ability to determine the evolution of code within a git repository","archived":false,"fork":false,"pushed_at":"2021-10-26T01:27:47.000Z","size":59,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-04T17:24:10.445Z","etag":null,"topics":["git","hacktoberfest","hacktoberfest2021","ownership","rubygem"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kevinjalbert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-02-20T03:13:30.000Z","updated_at":"2021-10-26T01:27:50.000Z","dependencies_parsed_at":"2022-09-02T13:11:12.243Z","dependency_job_id":null,"html_url":"https://github.com/kevinjalbert/git_evolution","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/kevinjalbert/git_evolution","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinjalbert%2Fgit_evolution","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinjalbert%2Fgit_evolution/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinjalbert%2Fgit_evolution/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinjalbert%2Fgit_evolution/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevinjalbert","download_url":"https://codeload.github.com/kevinjalbert/git_evolution/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinjalbert%2Fgit_evolution/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32547645,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T19:18:06.202Z","status":"ssl_error","status_checked_at":"2026-05-02T19:16:21.335Z","response_time":132,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","hacktoberfest","hacktoberfest2021","ownership","rubygem"],"created_at":"2024-10-30T06:08:35.884Z","updated_at":"2026-05-02T19:32:19.919Z","avatar_url":"https://github.com/kevinjalbert.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GitEvolution\n\n[![CI](https://github.com/kevinjalbert/git_evolution/actions/workflows/main.yml/badge.svg)](https://github.com/kevinjalbert/git_evolution/actions/workflows/main.yml)\n[![Coverage Status](https://coveralls.io/repos/kevinjalbert/git_evolution/badge.svg)](https://coveralls.io/r/kevinjalbert/git_evolution)\n[![Code Climate](https://codeclimate.com/github/kevinjalbert/git_evolution/badges/gpa.svg)](https://codeclimate.com/github/kevinjalbert/git_evolution)\n\nHave you ever curious how a specific line or group of lines got to that point? If those lines are captured in a git repository then the history is there. Being able to identify the _evolution_ of said lines to their current state can be tricky and cumbersome. `GitEvolution` aims to solve this problem and provide a quick, and informative approach to understanding the evolution of changes in a git repository.\n\nThis is incredibly useful when dealing with source lines in a software project as the commit messages often contain nuggets of information on decisions for change.\n\n## Installation\n\n`gem install git_evolution`\n\n## Usage\n\nCommand-line interface `--help`\n```\n$ git_evolution --help\n\nUsage: git_evolution [options] \u003cfile\u003e\n    -r, --range N:N                  The specified range of lines to consider within the file (optional)\n    -s, --since STRING               Consider the commits which are more recent than the specified time (optional)\n```\n\n## Example Scenario\n\nIf we were interesting in the source code evolution that lead to [rails's Array#forty_two](https://github.com/rails/rails/blob/7ba3a48/activesupport/lib/active_support/core_ext/array/access.rb#L70-L75):\n\n```\n$ git_evolution --range 70:75 ./rails/activesupport/lib/active_support/core_ext/array/access.rb\n\nCommits:\nutenmiki \u003cutenmiki@gmail.com\u003e (Thu Oct 31 23:20:15 2013 +0900) - 3f79d8423078f0671c8aa505ae199608d451663d\nAdd Rdoc document for Array#forty_two\n\nJeremy Kemper \u003cjeremy@bitsweat.net\u003e (Sat Mar 21 03:26:09 2009 -0700) - 83fd1ae122cf1ee4ea2c52e0bd963462163516ca\nConvert array extension modules to class reopens\n\nDavid Heinemeier Hansson \u003cdavid@loudthinking.com\u003e (Fri Nov 21 09:06:46 2008 +0100) - e50530ca3ab5db53ebc74314c54b62b91b932389\nReduced the number of literal aliases to the range that has actually seen personal use. With the massive savings in overhead, I was able to fit Array#forty_two\n\nPratik Naik \u003cpratiknaik@gmail.com\u003e (Sun Oct 5 22:16:26 2008 +0100) - a2932784bb71e72a78c32819ebd7ed2bed551e3e\nMerge docrails\n\nPratik Naik \u003cpratiknaik@gmail.com\u003e (Mon Jul 28 12:26:59 2008 +0100) - 6e754551254a8cc64e034163f5d0dc155b450388\nMerge docrails changes\n\nDavid Heinemeier Hansson \u003cdavid@loudthinking.com\u003e (Tue Jun 17 13:37:57 2008 -0500) - 22af62cf486721ee2e45bb720c42ac2f4121faf4\nAdded Array#second through Array#tenth as aliases for Array#[1] through Array#[9] [DHH]\n\nDavid Heinemeier Hansson \u003cdavid@loudthinking.com\u003e (Tue Nov 27 19:42:30 2007 +0000) - 4d177ae0d6d9f60c4000f45fb6f6df27317afbff\nAdded Array#from and Array#to that behaves just from String#from and String#to [DHH]\n\n--------------------------------------------------------------------------------\n\nOwnership (Commits):\nDavid Heinemeier Hansson \u003cdavid@loudthinking.com\u003e - 3/7 (42.86%)\nPratik Naik \u003cpratiknaik@gmail.com\u003e - 2/7 (28.57%)\nJeremy Kemper \u003cjeremy@bitsweat.net\u003e - 1/7 (14.29%)\nutenmiki \u003cutenmiki@gmail.com\u003e - 1/7 (14.29%)\n\nOwnership (Changes):\nDavid Heinemeier Hansson \u003cdavid@loudthinking.com\u003e - 53/84 (63.1%)\nPratik Naik \u003cpratiknaik@gmail.com\u003e - 20/84 (23.81%)\nJeremy Kemper \u003cjeremy@bitsweat.net\u003e - 9/84 (10.71%)\nutenmiki \u003cutenmiki@gmail.com\u003e - 2/84 (2.38%)\n```\n\n`GitEvolution` provides a succinct output of the commits which contains any changes which lead to the current state. Its quick to see that [e50530ca3ab5db53ebc74314c54b62b91b932389](https://github.com/rails/rails/commit/e50530ca3ab5db53ebc74314c54b62b91b932389) was the introduction point for `Array#forty_two`.\n\nIn addition we have some _ownership_ information with respect to commits and changes. The ownership information can be used to identify _who_ to follow up with for additional context. In time new metrics and analysis could be attached to the output (i.e., factoring in time for ownership, types of changes, identifying file modifications such as movement or renames, etc...)\n\n## The Other (Hard) Way\n\nIf we were to identify the commit which introduced `Array#forty_two` we have two main options `git blame` and `git log`:\n\n### Using `git blame`\nI highly advise against this approach as it involves a lot of manual work. You essentially use `git blame` to identify the previous commit which effects a line of concern within the area you are looking in.\n\n```\n$ git blame --follow ./activesupport/lib/active_support/core_ext/array/access.rb\n\n...\n83fd1ae1 (Jeremy Kemper            2009-03-21 03:26:09 -0700 70)   # Equal to \u003ctt\u003eself[41]\u003c/tt\u003e. Also known as accessing \"the reddit\".\n3f79d842 (utenmiki                 2013-10-31 23:20:15 +0900 71)   #\n3f79d842 (utenmiki                 2013-10-31 23:20:15 +0900 72)   #   (1..42).to_a.forty_two # =\u003e 42\n83fd1ae1 (Jeremy Kemper            2009-03-21 03:26:09 -0700 73)   def forty_two\n83fd1ae1 (Jeremy Kemper            2009-03-21 03:26:09 -0700 74)     self[41]\n4d177ae0 (David Heinemeier Hansson 2007-11-27 19:42:30 +0000 75)   end\n...\n```\n\nYou can then use a similar command to blame the parent git revision at that point.\n\n```\n$ git blame --follow 83fd1ae1^ -- ./activesupport/lib/active_support/core_ext/array/access.rb\n\n...\ne50530ca (David Heinemeier Hansson 2008-11-21 09:06:46 +0100 46)         # Equal to \u003ctt\u003eself[41]\u003c/tt\u003e. Also known as accessing \"the reddit\".\ne50530ca (David Heinemeier Hansson 2008-11-21 09:06:46 +0100 47)         def forty_two\ne50530ca (David Heinemeier Hansson 2008-11-21 09:06:46 +0100 48)           self[41]\n22af62cf (David Heinemeier Hansson 2008-06-17 13:37:57 -0500 49)         end\n...\n```\n\nAll the while you occasionally want to inspect the commit in more detail using `git show \u003ccommit-sha\u003e`. Eventually you will end up where you want to be.\n\n```\n$ git show e50530ca\n\ncommit e50530ca3ab5db53ebc74314c54b62b91b932389\nAuthor: David Heinemeier Hansson \u003cdavid@loudthinking.com\u003e\nDate:   Fri Nov 21 09:06:46 2008 +0100\n\n    Reduced the number of literal aliases to the range that has actually seen personal use. With the massive savings in overhead, I was able to fit Array#forty_two\n```\n\n### Using `git log`\nThe following `git log` command presents the entire file history (26 commits):\n\n```\n$ git log --follow ./activesupport/lib/active_support/core_ext/array/access.rb\n```\n\nThis works, but it is a lot more information to sift through.\n\nA better approach (which is what `GitEvolution` uses under the hood) presents the file history for only the concerned portion (7 commits):\n\n```\n$ git log -L70,75:./activesupport/lib/active_support/core_ext/array/access.rb\n```\n\nThe output isn't succinct, nor does it have ownership information. The command is also more verbose.\n\n### Editor\n\nI made a [Vim function](https://github.com/kevinjalbert/dotfiles/blob/eaca550/vim/vim/functions.vim#L1-L16) that allows me to visually select and call `git_evolution` using `ge` on the selected lines. This opens the output in a new buffer which I can then look through and yank commit SHAs if needed.\n\n## Contributing\n\n1. Fork it ( https://github.com/kevinjalbert/git_evolution/fork )\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create a new Pull Request\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinjalbert%2Fgit_evolution","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevinjalbert%2Fgit_evolution","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinjalbert%2Fgit_evolution/lists"}