coding4fun coding4fun - 5 days ago 4x
Git Question

git - changes to branch since created?

I'm always asking myself a set of questions about branches i've created that i've yet to determine how to accomplish:

  1. What files did i change in branch?

  2. What are the actually changes (diff) i made to the branch?

  3. What is the log of commits that i made to the branch?

Now i think if figured out how to get the hashes of all the commits that were committed to the branch but not merged into master using
git cherry master <branchname>
. With this i could go hash by hash and figure out everything but if you have a lot of commits this could be time consuming. Notice i'm not wanting to compare to current state of master. I think the key is knowing the hash of master that you created your branch off of but i'm not exactly sure how to determine this.


To find where your current checkout diverged from the master branch,

base=`git merge-base master HEAD`
echo $base

to find out what files have been changed since then,

git diff --name-only $base HEAD

to show the accumulated difference

git diff $base HEAD

When you want to describe an entire series of commits you can use the syntax in the answer Gabriele Petronella linked above, master..HEAD is shorthand for HEAD ^master which means "all commits reachable from HEAD, but not including commits reachable from master". Missing endpoints default to HEAD, so you can say git log --oneline master..