Do you know how to use the latest version of the file from all branches? The problem is that to use the latest version, I have to checkout the branch, but I do not know which branch is the latest version.
So I may use a file that is obsolete from another branch, but I do not know that another branch has the last version.
Partial Solution: Create a new branch where the last version of the file will be.
Can it be solved otherwise? Thanks
I would guess that you using git the wrong way if you're asking this kind of question.
The notion of "latest version" of a file has no real sense in git.
The notion of "next version to be released" of a file depends on your branch and release workflow, but should be deterministic.
Maybe you should explain your root need for better understanding of want you're trying to achieve.
But, to strictly answer your question:
To find the latest commit that modified a file:
git log -1 --date-order --all --format=format:%H -- path/to/file/in/repository
This will give you the commit hash.
If you want to retrieve the content of the file in this commit:
git show ${COMMIT_HASH}:path/to/file/in/repository
If you want to find the branches containing this commit:
git branch --contains ${COMMIT_HASH}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With