# Git history best practices

**URL:** <https://discourse.pangeo.io/t/git-history-best-practices/731>\
**Category:** Meta\
**Created:** [July 10, 2020, 4:13pm UTC](https://discourse.pangeo.io/t/git-history-best-practices/731 "2020-07-10T16:13:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![JessicaS11](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/jessicas11/32/229_2.png) [@JessicaS11](https://discourse.pangeo.io/u/JessicaS11)\
**Post date:** [July 10, 2020, 4:13pm UTC](https://discourse.pangeo.io/t/git-history-best-practices/731/1 "2020-07-10T16:13:16Z")

</div>

I’m wondering what the best/standard practices are for maintaining a project’s git history. I’ve been improving my efforts to have a clean, simple commit history, but eventually the history will get to be pretty long if it goes back to the project’s very first commit (I’m thinking for projects operating for years to decades or more, or in my present case, from old projects when I was first learning to use git and didn’t use squash commits and have lots of long commit messages). Does the git history ever get archived, squashed, or removed, or is project history expected to stick around in perpetuity (like, can I see Python 1.0’s very first commit?). I try hard to keep on top of digital clutter, and this seems like something getting into that category, especially for older projects, but I don’t want to remove an archived repo’s git history if that’s considered bad practice.

---

<div class="post-metadata">

**Author:** ![jthetzel](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/jthetzel/32/423_2.png) [@jthetzel](https://discourse.pangeo.io/u/jthetzel)\
**Post date:** [July 11, 2020, 6:31pm UTC](https://discourse.pangeo.io/t/git-history-best-practices/731/2 "2020-07-11T18:31:05Z")

</div>

For reference, here are the first few commits for Python, with the initial commit dated 1990-08-09:

> **[python/cpython](https://github.com/python/cpython/commits/master?after=344dce312a0cf86d5a5772d54843cc179acaf6e3%2B107760)**
>
> The Python programming language. Contribute to python/cpython development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![keniseli](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/keniseli/32/436_2.png) [@keniseli](https://discourse.pangeo.io/u/keniseli)\
**Post date:** [July 13, 2020, 12:57pm UTC](https://discourse.pangeo.io/t/git-history-best-practices/731/3 "2020-07-13T12:57:05Z")

</div>

I think the git history is never actively archived, squashed or modified in any other way.

In our maintenance (and other) projects we follow team-defined standards for git messages:

- Link a unique issue key: This helps to understand solutions when analyzing code because of bugs or unexpected behaviour
- In one sentence tell (imperatively) what this commit does: This helps having a concise and consistent history
- Syntax and orthographics matter! Writing proper messages without typos, correct punctuation and gramatically correct structures supports readability and gives an overall feeling of quality.

I’d strongly suggest not to change anything in your git history. Removing parts of the history removes a lot of context information that could be relevant when working on a specific part of your system.

Does this help you?

---

<div class="post-metadata">

**Author:** ![JessicaS11](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/jessicas11/32/229_2.png) [@JessicaS11](https://discourse.pangeo.io/u/JessicaS11)\
**Post date:** [July 13, 2020, 3:34pm UTC](https://discourse.pangeo.io/t/git-history-best-practices/731/4 "2020-07-13T15:34:49Z")

</div>

Thanks @jthetzel and @keniseli! It sounds like the best practice is to just keep the whole git history, for better or worse, and aim to just make it the best it can be going forward. Thanks for this advice. : )

---

<div class="post-metadata">

**Author:** ![jthetzel](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/jthetzel/32/423_2.png) [@jthetzel](https://discourse.pangeo.io/u/jthetzel)\
**Post date:** [July 13, 2020, 7:05pm UTC](https://discourse.pangeo.io/t/git-history-best-practices/731/5 "2020-07-13T19:05:49Z")

</div>

Commit message style is a personal or project preference. However, Conventional Commits has codified useful best practices.

[https://www.conventionalcommits.org/](https://www.conventionalcommits.org/)

---

<div class="post-metadata">

**Author:** ![jthetzel](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/jthetzel/32/423_2.png) [@jthetzel](https://discourse.pangeo.io/u/jthetzel)\
**Post date:** [July 14, 2020, 9:37am UTC](https://discourse.pangeo.io/t/git-history-best-practices/731/6 "2020-07-14T09:37:29Z")

</div>

URL encoding appers to mangle the link. It should be:  
`https://github.com/python/cpython/commits/master?after=344dce312a0cf86d5a5772d54843cc179acaf6e3+107760`

But here’s the first Python commit:

> <https://github.com/python/cpython/commit/7f777ed95a19224294949e1b4ce56bbffcb1fe9f>

---

<div class="post-metadata">

**Author:** ![nbren12](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.pangeo.io/nbren12/32/386_2.png) [@nbren12](https://discourse.pangeo.io/u/nbren12)\
**Post date:** [July 31, 2020, 6:54am UTC](https://discourse.pangeo.io/t/git-history-best-practices/731/7 "2020-07-31T06:54:30Z")

</div>

FWIW. I think the hardest part for me about writing good commits is my disorganized development approach. If you actually plan/chunk the work to occur in “commit” sized pieces, then the commit description will be easy to write. And the history will be much more useful.For example, it’s much easier to undo a bug if it isn’t lumped into one commit with unrelated code. Conversely it’s not easy to write a good commit message for a random set of unrelated changes.

But yah. The history will probably stick around. It’s nice in case you want to blame a colleague for a bug they introduced months back.
