Can you check out the future commit file with git?

Background . We just discovered a recently created bug in our code (it wasn't always there). We didn't have an automated test. We just created it. After that, we also made a few changes, so the test is not in HEAD

master

.

I want to know if I go back, say 30 commits, can I somehow get this newly created test into my working directory? This way I can run git bisect

and run an automatic test run instead of manually checking it for each iteration. I thought I could check the check-test and reset --mixed

to get a file in my working directory without being in the index, but I wanted to know if there is an easier way when you add tests after the fact.

+3


source to share


2 answers


Yes. You can use git checkout <revision> -- path/to/file

to check a specific version of a commit file.



+3


source


Since you are just hunting for bugs, you can simply rewrite history (into a new branch) to look for bugs.

You can git rebase -i <most recent working commit>

, insert a commit that adds a test immediately after a production commit, and rebase tests throughout your history. Then you can safely divide in half.



If you just want to test tests "from the future", be sure to limit the division in half before you add tests or git

complain about adding test files.

0


source







All Articles