Skip to content

Instantly share code, notes, and snippets.

@xcatliu
Created September 22, 2017 04:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xcatliu/ddc2aec4e4cde0824429477f7ea233cd to your computer and use it in GitHub Desktop.
Save xcatliu/ddc2aec4e4cde0824429477f7ea233cd to your computer and use it in GitHub Desktop.
Get the change list when git push
# Find the common ancestor of current hash and origin/master
# https://stackoverflow.com/questions/1549146/find-common-ancestor-of-two-git-branches
# Command inside `` will be executed and pass to the variable
common_ancestor=`git merge-base HEAD origin/master`
# --diff-filter=ACMRT Only show files which is appended, copied, modified, renamed or type-changed
changelist=`git diff $common_ancestor HEAD --name-only --diff-filter=ACMRT`
@gucong3000
Copy link

貌似可以简化为一行

git diff ...origin/master --name-only --diff-filter=ACMRT

@xcatliu
Copy link
Author

xcatliu commented Sep 26, 2017

@gucong3000 我试了下,貌似不行啊,输出是空的

@sstruct
Copy link

sstruct commented Sep 27, 2019

git diff origin/master --name-only --diff-filter=ACMRT

这样和你的结果是一样的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment