Php get Commit list of specfic Git Branch
791
I want to get commits of specific branch. following is my code
exec("git log $branch", $logs);
$branch may be master or any other branch. But this give all commits.
Answer
Solution:
Sure: it gives all commits reachable from
master
HEAD, which are all commit even if they are part of another branch. Up to the very first one (usually done on the master branch)Even if you were to use another branch, you would still get all commit reachable from that other branch HEAD, even if they are part of
master
(assuming that other branch was done from one of master commits)That is why you need two parameters: one which will start the commit retrieval, one which will stop it:
Put that in your Php command, and you will get only the commits you are after.