Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 17th, 2012  |  syntax: None  |  size: 0.50 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to see if local git repo and remote repo are same commit?
  2. git fetch origin
  3.        
  4. git rev-parse master
  5.        
  6. git rev-parse origin/master
  7.        
  8. remote=$(
  9.     git ls-remote -h origin master |
  10.     awk '{print $1}'
  11. )
  12. local=$(git rev-parse HEAD)
  13.  
  14. printf "Local : %snRemote: %sn" $local $remote
  15.  
  16. if [[ $local == $remote ]]; then
  17.     echo "Commits match."
  18. else
  19.     echo "Commits don't match."
  20. fi
  21.        
  22. Local : 9e1b4dc286acb442f7f604be7916db660b9d70cd
  23. Remote: 9e1b4dc286acb442f7f604be7916db660b9d70cd
  24. Commits match.