0

I have a quick question regarding git commits and branches.

Say that I want to get two commit idn based on two dates.

I do the bellow on the "Master Branch".

git rev-list --since='2015-01-01' --reverse origin/master | head -1
git rev-list --until='2015-06-30' origin/master | head -1

Now if I switch branch,I.E I do a:

git checkout testing

will I only get commit ID'n that is from the testing branch or will I also get commit ID'n from all other branches including the master branch?

A simple yes no will do, I want to be sure that I don't get any commits from the master branch so that I only get code from commits on the testing branch and not code from any other branch.

Thanks in advance.

1 Answer 1

1

From documentation for git rev-list:

List commits that are reachable by following the parent links from the given commit(s), but exclude commits that are reachable from the one(s) given with a ^ in front of them. The output is given in reverse chronological order by default.

It doesn't matter which branch do you have checked out. You have to specify branch (or target commit in general) as parameter of the rev-list command.

The answer to your question is that you will get the same output even if you are on different branch. To get those commits for testing branch you need to use:

git rev-list --since='2015-01-01' --reverse testing | head -1
git rev-list --until='2015-06-30' testing | head -1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .