Git Bash script to check whether repo has any commits? -


I have a script on which I need to work differently if there is one, which is one or more , Commits. What is the best way to do this?

Something like this will appear in the proxy code.

  #! / Bin / bash if [[`git log_count`] ==" 0 "]]; Then there is no commodity for this repo. # What goods ... and echo are "one or more committed!" # What are the other things?   

Any ideas?

you can

  git rev-parse -verify HEAD   

(after :)

  1. This is a pipeline command, and its behavior vs. " git diff " There is very little possibility to change
  2. I find it more pronounced rev-parse -verify means "is this a valid object name?"

    This is your show-ref .
    You ask "Is there anything in this safe / head in the safe?"
    I ask, "what current head exists?"

    In practice, both of these are fair tests, because once you have a branch, so to achieve the HEAD , some mock values ​​will indicate manually lack of editing It is very difficult to do. But you can prefer more than one.

Comments