I have the code in bat scripts given below to checkout the code by giving particular date. If I gave date=2019-10-25 it work properly but if I give 2019-10-05 it will not work properly. Is there any method to give single digit day.
git rev-list -n1 --before={%date%} branch | xargs git checkout
Asked
Active
Viewed 151 times
0

Nicolas Pepinster
- 5,413
- 2
- 30
- 48

pacchu
- 1
- 2
-
The example you gave is valid. Can you double-check that there actually *are* commits older than this in the repo? Also, what do you mean by "not happen properly"? Do you get an error? or the expected detached HEAD? – Romain Valeri Nov 04 '19 at 14:11
-
@RomainValeri No error will come but the checkout will not happen for the date 2019-10-05 , Any idea how to give 05 as date in gitlab. – pacchu Nov 04 '19 at 14:18
-
Related (but it looks like this should parse as yyyy-mm-dd already): https://stackoverflow.com/q/14023794/1256452 – torek Nov 04 '19 at 17:38
-
What do you get if you just use `git rev-list -n1 --before=2019-10-05`, without a pipe to xargs? – torek Nov 04 '19 at 17:39
-
@torek The git checkout will not happen properly as code committed for the date 2019-10-05 from gitlab if we remove `| xargs git checkout `. – pacchu Nov 05 '19 at 04:34
-
@pacchu: of course not. What I wanted to know is what the actual *output* is, since that determines what xargs will do. Do you get exactly one commit hash ID? Or do you, e.g., get no commit hash ID at all? – torek Nov 05 '19 at 06:40
-
@torek: I am getting commit hash ID. The problem I am facing is that when I do difference of 2 committed date for eg:- from 2019-10-01 to 2019-10-04. There is no code difference even though I have checked in the code between that date. I don't know how to resolve this issues. The code difference is proper if we give date for eg:- from 2019-10-11 to 2019-10-15. The problem with day that starts with 0. Can you help me on this. – pacchu Nov 05 '19 at 12:26
-
OK, that's progress of a sort. *What* commit hash ID do you get? Do you get the same hash ID for both `git rev-list` commands? Let's first narrow down exactly which commits `git rev-list` is picking, and examine the surrounding commits in the graph to see why it's picking those. Perhaps it has something to do with author date vs committer date. Perhaps it is because something is going wrong with the date parsing. But one way or another, it would help to know *what* is happening before we go off into *why* it might be happening... – torek Nov 05 '19 at 16:29
-
Once you have both hash IDs, try viewing "nearby" commits under `git log --pretty=fuller`, which displays *both* date-and-time-stamps that appear in each commit. I'd suggest also using `git log --graph`, perhaps with `--oneline`, and/or a graphical viewer like `gitk`, to view the interconnections between the commits. – torek Nov 05 '19 at 16:31