Git compare: a quick way to compare two branches

Today I want to share with you a small bash script that I have been using successfully for several years now.



To begin with, I will describe a situation that often occurs to me to this day, which prompted me to write a script. While working on a new task, I periodically save the current state of the project in the gita, while the commits themselves do not carry any semantic load either in terms of content or commit messages.



As a result, the local branch of the finished task looks something like this:



image



The next stage comes:



1) (feature-all-private )



image



2) (feature-public ):



image



: , , (- , )



image



: , — git-cmp

— bash- .

"" (feature-private) "" (feature-public):



git checkout feature-public
git cmp feature-private


, :



 $ git cmp feature-private                                                       
common parent commit: 758d3fa                  
cleaning...                                                                     
...done


git-diff:



 $ git cmp feature-private
common parent commit: 758d3fa
diff --git a/test.txt b/test.txt
index 1e65656..2013c09 100644
--- a/test.txt
+++ b/test.txt
@@ -1,4 +1,4 @@
-oldLine
+newLine
cleaning...
...done


, :



image



I hope this script will be useful to someone else

Sources uploaded on github

Pictures were created with codepen.io



Update: It turns out that this functionality is already implemented in the standard git set and is called git-diff




All Articles