Why does git commit –amend change the hash even if I don’t make any changes?

Yes, it’s the commit timestamp. Inspecting the contents of the two commits reveals: $ git cat-file commit 82c7363bcfd727fe2d6b0a98412f71a10c8849c9 tree d87cbcba0e2ede0752bdafc5938da35546803ba5 author Thomas <xxx> 1400700200 +0200 committer Thomas <xxx> 1400700200 +0200 hello $ git cat-file commit 7432fcf82b65d9d757efd73ef7d6bff4707f99bd tree d87cbcba0e2ede0752bdafc5938da35546803ba5 author Thomas <xxx> 1400700200 +0200 committer Thomas <xxx> 1400700214 +0200 hello If you amended in the same … Read more

git: change one line in file for the complete history

Here’s a command that will remove an offending line from a file’s history in all your branches: git filter-branch –tree-filter ‘sed -i “/sensitive information/ d” filename’ — –all This checks out every revision, runs the sed command on it, then commits that revision back. The sed command in this case matches any lines containing the … Read more

What are the differences between ‘revert’, ‘amend,’ ‘rollback’, and ‘undo’ a commit?

The terms revert and amend have a well defined meaning in Git. In contrast, rollback and undo do not have such a well defined meaning, and are open to interpretation. Reverting a commit… …means creating (on the current branch) a new commit that applies the inverse changes that another commit introduced. It’s the preferred approach … Read more

Accidentally pushed commit: change git commit message

Easiest solution (but please read this whole answer before doing this): git rebase -i <hash-of-commit-preceding-the-incorrect-one> In the editor that opens, change pick to reword on the line for the incorrect commit. Save the file and close the editor. The editor will open again with the incorrect commit message. Fix it. Save the file and close … Read more

tech