Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I generate a git diff of what's changed since the last time I pulled?

Tags:

git

diff

rake

pull

I'd like to script, preferably in rake, the following actions into a single command:

  1. Get the version of my local git repository.
  2. Git pull the latest code.
  3. Git diff from the version I extracted in step #1 to what is now in my local repository.

In other words, I want to get the latest code form the central repository and immediately generate a diff of what's changed since the last time I pulled.

like image 477
Teflon Ted Avatar asked Sep 14 '08 00:09

Teflon Ted


People also ask

How do I see what changed after git pull?

git fetch git log --name-status origin/master.. Will show you what commits you are about to retrieve, along with the names of the files. Based upon this reply the command "git log --graph -p" is doing a nice job. It shows tree information about the history and code changes as well.

How do I see changes in git diff?

You can run the git diff HEAD command to compare the both staged and unstaged changes with your last commit. You can also run the git diff <branch_name1> <branch_name2> command to compare the changes from the first branch with changes from the second branch.

Which command shows the changes between commits git diff git status?

The git diff command displays the differences between files in two commits or between a commit and your current repository. You can see what text has been added to, removed from, and changed in a file. By default, the git diff command displays any uncommitted changes to your repository.


1 Answers

You could do this fairly simply with refspecs.

git pull origin git diff @{1}.. 

That will give you a diff of the current branch as it existed before and after the pull. Note that if the pull doesn't actually update the current branch, the diff will give you the wrong results. Another option is to explicitly record the current version:

current=`git rev-parse HEAD` git pull origin git diff $current.. 

I personally use an alias that simply shows me a log, in reverse order (i.e. oldest to newest), sans merges, of all the commits since my last pull. I run this every time my pull updates the branch:

git config --global alias.lcrev 'log --reverse --no-merges --stat @{1}.. 
like image 85
Lily Ballard Avatar answered Sep 24 '22 06:09

Lily Ballard