I have a bash script that iterates (forward in time) through a git repo. I have a curr_hash
variable that represent the current hash, and I want to end my loop when curr_hash
is the latest commit (which means that I can't iterate forward in time anymore). How do I do this?
Asked
Active
Viewed 61 times
1

Software Dev
- 910
- 3
- 10
- 27
-
2That's a really really bad way to do it. Instead, do `git rev-list --all --reverse`, that will get you a timestamp-ordered list of commits, latest last. – jthill Aug 06 '19 at 01:37
1 Answers
0
Assuming you want to move forward on a specific branch (because you know which branch your current commit is part of), you can use git rev-list --topo-order
as in here or there.
git rev-list --topo-order curr_hash ..<yourBranch>
You can then reverse that list, and loop in the proper order.

VonC
- 1,262,500
- 529
- 4,410
- 5,250