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.
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.
But this give all commits.
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)
x--x--x--X (master)
\
--o--o--O (anotherBranch)
git log anotherBranch = O-o-o-X-x-x-x
That is why you need two parameters: one which will start the commit retrieval, one which will stop it:
git checkout mybranch
git log --all --not $(git rev-list --no-walk \
--exclude=refs/heads/mybranch \
--exclude=HEAD \
--all)
Put that in your Php command, and you will get only the commits you are after.