Test old commit in Git Repository












0















I currently have a Project(JavaScript) with a bug in it and I am sure that I fixed it sometime ago, now my Question is how to revert to an old commit and check that Version on my localhost.



But I do not want to loose any changes in my git repo I just want to check how the Project look at commit X, how do I manage that.



I am using gitkraken as a gui.










share|improve this question



























    0















    I currently have a Project(JavaScript) with a bug in it and I am sure that I fixed it sometime ago, now my Question is how to revert to an old commit and check that Version on my localhost.



    But I do not want to loose any changes in my git repo I just want to check how the Project look at commit X, how do I manage that.



    I am using gitkraken as a gui.










    share|improve this question

























      0












      0








      0








      I currently have a Project(JavaScript) with a bug in it and I am sure that I fixed it sometime ago, now my Question is how to revert to an old commit and check that Version on my localhost.



      But I do not want to loose any changes in my git repo I just want to check how the Project look at commit X, how do I manage that.



      I am using gitkraken as a gui.










      share|improve this question














      I currently have a Project(JavaScript) with a bug in it and I am sure that I fixed it sometime ago, now my Question is how to revert to an old commit and check that Version on my localhost.



      But I do not want to loose any changes in my git repo I just want to check how the Project look at commit X, how do I manage that.



      I am using gitkraken as a gui.







      git git-revert gitkraken






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 12:24









      Jon not doe xxJon not doe xx

      737




      737
























          2 Answers
          2






          active

          oldest

          votes


















          2















          • Be sure you have no uncommited changes; commit or stash them if necessary

          • Create a new branch at your current HEAD (using the Branch button)

          • Search the commit you want to take a look at

          • Right click the commit, choose Reset <branchname> to this commit > Hard - discard all changes. This will reset the branch you just created to this commit.

          • You travelled back in time. Test and check everything you need to. If you want to go back to the present, just check out your original branch.


          EDIT:
          There's an even easier way!




          • Be sure you have no uncommited changes; commit or stash them if necessary

          • Search the commit you want to take a look at

          • Right click the commit, choose Create branch here. Enter a branch name. This will create a branch at this commit.

          • Check out the newly created branch by double-clicking.

          • You travelled back in time. Test and check everything you need to. If you want to go back to the present, just check out your original branch.






          share|improve this answer


























          • A good gitkraken answer! I see gitkraken doesn't just checkout to a commit.

            – clmno
            Nov 14 '18 at 12:41











          • This worked thanks alot, is this a good "practice" for issues like this?

            – Jon not doe xx
            Nov 14 '18 at 13:43











          • Yes. It's very cheap to create branches in git, so it's completely legit to create some to move around in your repository's history. It's generally advisable to create backup branches before you perform potentially destructive operations like rebases or hard resets. Having that said, it's by no means necessary to create branches for this purpose; when you use git via command line, you can use git checkout <commit-id> to checkout commits directly; although this will lead to a detached HEAD state. In gitkraken, however, you will always need to work with branches.

            – kowsky
            Nov 14 '18 at 13:54



















          0














          If you are unsure when the bug was introduced/fiex you can use the bisect approach of git: https://git-scm.com/docs/git-bisect



          git bisect start
          git bisect bad COMMIT_KNOWN_TO_FAIL
          git bisect good COMMIT_KNOWN_TO_PASS


          Then git will select a commit in the middle. You can do your check and depending on the result of your test you call:



           git bisect good


          if the test passes and



           git bisect bad


          if the test fails.



          Then git selects another commit towards the former good if the test failed and towards the **bad* if the test passed.



          Since you're looking for when the problem disappeard you might have to switch the meaning of "good" and "bad" when continuing...



          when you identified the malicios commit call



          git bisect reset





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300194%2ftest-old-commit-in-git-repository%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            2















            • Be sure you have no uncommited changes; commit or stash them if necessary

            • Create a new branch at your current HEAD (using the Branch button)

            • Search the commit you want to take a look at

            • Right click the commit, choose Reset <branchname> to this commit > Hard - discard all changes. This will reset the branch you just created to this commit.

            • You travelled back in time. Test and check everything you need to. If you want to go back to the present, just check out your original branch.


            EDIT:
            There's an even easier way!




            • Be sure you have no uncommited changes; commit or stash them if necessary

            • Search the commit you want to take a look at

            • Right click the commit, choose Create branch here. Enter a branch name. This will create a branch at this commit.

            • Check out the newly created branch by double-clicking.

            • You travelled back in time. Test and check everything you need to. If you want to go back to the present, just check out your original branch.






            share|improve this answer


























            • A good gitkraken answer! I see gitkraken doesn't just checkout to a commit.

              – clmno
              Nov 14 '18 at 12:41











            • This worked thanks alot, is this a good "practice" for issues like this?

              – Jon not doe xx
              Nov 14 '18 at 13:43











            • Yes. It's very cheap to create branches in git, so it's completely legit to create some to move around in your repository's history. It's generally advisable to create backup branches before you perform potentially destructive operations like rebases or hard resets. Having that said, it's by no means necessary to create branches for this purpose; when you use git via command line, you can use git checkout <commit-id> to checkout commits directly; although this will lead to a detached HEAD state. In gitkraken, however, you will always need to work with branches.

              – kowsky
              Nov 14 '18 at 13:54
















            2















            • Be sure you have no uncommited changes; commit or stash them if necessary

            • Create a new branch at your current HEAD (using the Branch button)

            • Search the commit you want to take a look at

            • Right click the commit, choose Reset <branchname> to this commit > Hard - discard all changes. This will reset the branch you just created to this commit.

            • You travelled back in time. Test and check everything you need to. If you want to go back to the present, just check out your original branch.


            EDIT:
            There's an even easier way!




            • Be sure you have no uncommited changes; commit or stash them if necessary

            • Search the commit you want to take a look at

            • Right click the commit, choose Create branch here. Enter a branch name. This will create a branch at this commit.

            • Check out the newly created branch by double-clicking.

            • You travelled back in time. Test and check everything you need to. If you want to go back to the present, just check out your original branch.






            share|improve this answer


























            • A good gitkraken answer! I see gitkraken doesn't just checkout to a commit.

              – clmno
              Nov 14 '18 at 12:41











            • This worked thanks alot, is this a good "practice" for issues like this?

              – Jon not doe xx
              Nov 14 '18 at 13:43











            • Yes. It's very cheap to create branches in git, so it's completely legit to create some to move around in your repository's history. It's generally advisable to create backup branches before you perform potentially destructive operations like rebases or hard resets. Having that said, it's by no means necessary to create branches for this purpose; when you use git via command line, you can use git checkout <commit-id> to checkout commits directly; although this will lead to a detached HEAD state. In gitkraken, however, you will always need to work with branches.

              – kowsky
              Nov 14 '18 at 13:54














            2












            2








            2








            • Be sure you have no uncommited changes; commit or stash them if necessary

            • Create a new branch at your current HEAD (using the Branch button)

            • Search the commit you want to take a look at

            • Right click the commit, choose Reset <branchname> to this commit > Hard - discard all changes. This will reset the branch you just created to this commit.

            • You travelled back in time. Test and check everything you need to. If you want to go back to the present, just check out your original branch.


            EDIT:
            There's an even easier way!




            • Be sure you have no uncommited changes; commit or stash them if necessary

            • Search the commit you want to take a look at

            • Right click the commit, choose Create branch here. Enter a branch name. This will create a branch at this commit.

            • Check out the newly created branch by double-clicking.

            • You travelled back in time. Test and check everything you need to. If you want to go back to the present, just check out your original branch.






            share|improve this answer
















            • Be sure you have no uncommited changes; commit or stash them if necessary

            • Create a new branch at your current HEAD (using the Branch button)

            • Search the commit you want to take a look at

            • Right click the commit, choose Reset <branchname> to this commit > Hard - discard all changes. This will reset the branch you just created to this commit.

            • You travelled back in time. Test and check everything you need to. If you want to go back to the present, just check out your original branch.


            EDIT:
            There's an even easier way!




            • Be sure you have no uncommited changes; commit or stash them if necessary

            • Search the commit you want to take a look at

            • Right click the commit, choose Create branch here. Enter a branch name. This will create a branch at this commit.

            • Check out the newly created branch by double-clicking.

            • You travelled back in time. Test and check everything you need to. If you want to go back to the present, just check out your original branch.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 14 '18 at 12:44

























            answered Nov 14 '18 at 12:38









            kowskykowsky

            3,2961324




            3,2961324













            • A good gitkraken answer! I see gitkraken doesn't just checkout to a commit.

              – clmno
              Nov 14 '18 at 12:41











            • This worked thanks alot, is this a good "practice" for issues like this?

              – Jon not doe xx
              Nov 14 '18 at 13:43











            • Yes. It's very cheap to create branches in git, so it's completely legit to create some to move around in your repository's history. It's generally advisable to create backup branches before you perform potentially destructive operations like rebases or hard resets. Having that said, it's by no means necessary to create branches for this purpose; when you use git via command line, you can use git checkout <commit-id> to checkout commits directly; although this will lead to a detached HEAD state. In gitkraken, however, you will always need to work with branches.

              – kowsky
              Nov 14 '18 at 13:54



















            • A good gitkraken answer! I see gitkraken doesn't just checkout to a commit.

              – clmno
              Nov 14 '18 at 12:41











            • This worked thanks alot, is this a good "practice" for issues like this?

              – Jon not doe xx
              Nov 14 '18 at 13:43











            • Yes. It's very cheap to create branches in git, so it's completely legit to create some to move around in your repository's history. It's generally advisable to create backup branches before you perform potentially destructive operations like rebases or hard resets. Having that said, it's by no means necessary to create branches for this purpose; when you use git via command line, you can use git checkout <commit-id> to checkout commits directly; although this will lead to a detached HEAD state. In gitkraken, however, you will always need to work with branches.

              – kowsky
              Nov 14 '18 at 13:54

















            A good gitkraken answer! I see gitkraken doesn't just checkout to a commit.

            – clmno
            Nov 14 '18 at 12:41





            A good gitkraken answer! I see gitkraken doesn't just checkout to a commit.

            – clmno
            Nov 14 '18 at 12:41













            This worked thanks alot, is this a good "practice" for issues like this?

            – Jon not doe xx
            Nov 14 '18 at 13:43





            This worked thanks alot, is this a good "practice" for issues like this?

            – Jon not doe xx
            Nov 14 '18 at 13:43













            Yes. It's very cheap to create branches in git, so it's completely legit to create some to move around in your repository's history. It's generally advisable to create backup branches before you perform potentially destructive operations like rebases or hard resets. Having that said, it's by no means necessary to create branches for this purpose; when you use git via command line, you can use git checkout <commit-id> to checkout commits directly; although this will lead to a detached HEAD state. In gitkraken, however, you will always need to work with branches.

            – kowsky
            Nov 14 '18 at 13:54





            Yes. It's very cheap to create branches in git, so it's completely legit to create some to move around in your repository's history. It's generally advisable to create backup branches before you perform potentially destructive operations like rebases or hard resets. Having that said, it's by no means necessary to create branches for this purpose; when you use git via command line, you can use git checkout <commit-id> to checkout commits directly; although this will lead to a detached HEAD state. In gitkraken, however, you will always need to work with branches.

            – kowsky
            Nov 14 '18 at 13:54













            0














            If you are unsure when the bug was introduced/fiex you can use the bisect approach of git: https://git-scm.com/docs/git-bisect



            git bisect start
            git bisect bad COMMIT_KNOWN_TO_FAIL
            git bisect good COMMIT_KNOWN_TO_PASS


            Then git will select a commit in the middle. You can do your check and depending on the result of your test you call:



             git bisect good


            if the test passes and



             git bisect bad


            if the test fails.



            Then git selects another commit towards the former good if the test failed and towards the **bad* if the test passed.



            Since you're looking for when the problem disappeard you might have to switch the meaning of "good" and "bad" when continuing...



            when you identified the malicios commit call



            git bisect reset





            share|improve this answer




























              0














              If you are unsure when the bug was introduced/fiex you can use the bisect approach of git: https://git-scm.com/docs/git-bisect



              git bisect start
              git bisect bad COMMIT_KNOWN_TO_FAIL
              git bisect good COMMIT_KNOWN_TO_PASS


              Then git will select a commit in the middle. You can do your check and depending on the result of your test you call:



               git bisect good


              if the test passes and



               git bisect bad


              if the test fails.



              Then git selects another commit towards the former good if the test failed and towards the **bad* if the test passed.



              Since you're looking for when the problem disappeard you might have to switch the meaning of "good" and "bad" when continuing...



              when you identified the malicios commit call



              git bisect reset





              share|improve this answer


























                0












                0








                0







                If you are unsure when the bug was introduced/fiex you can use the bisect approach of git: https://git-scm.com/docs/git-bisect



                git bisect start
                git bisect bad COMMIT_KNOWN_TO_FAIL
                git bisect good COMMIT_KNOWN_TO_PASS


                Then git will select a commit in the middle. You can do your check and depending on the result of your test you call:



                 git bisect good


                if the test passes and



                 git bisect bad


                if the test fails.



                Then git selects another commit towards the former good if the test failed and towards the **bad* if the test passed.



                Since you're looking for when the problem disappeard you might have to switch the meaning of "good" and "bad" when continuing...



                when you identified the malicios commit call



                git bisect reset





                share|improve this answer













                If you are unsure when the bug was introduced/fiex you can use the bisect approach of git: https://git-scm.com/docs/git-bisect



                git bisect start
                git bisect bad COMMIT_KNOWN_TO_FAIL
                git bisect good COMMIT_KNOWN_TO_PASS


                Then git will select a commit in the middle. You can do your check and depending on the result of your test you call:



                 git bisect good


                if the test passes and



                 git bisect bad


                if the test fails.



                Then git selects another commit towards the former good if the test failed and towards the **bad* if the test passed.



                Since you're looking for when the problem disappeard you might have to switch the meaning of "good" and "bad" when continuing...



                when you identified the malicios commit call



                git bisect reset






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 14 '18 at 21:02









                Timothy TruckleTimothy Truckle

                8,42621834




                8,42621834






























                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53300194%2ftest-old-commit-in-git-repository%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    The Sandy Post

                    Danny Elfman

                    Pages that link to "Head v. Amoskeag Manufacturing Co."