Reversal of Commit

1

I have a question, I would like to return to a certain commit and assign this commit to a certain branch without losing a history, for example.

I have a development branch, where it is read by a URL, when I am developing and I want to show my client what I did in development, I commited and good, but it can happen that I did not go to production at that very moment, then I would have to return to the initial commite put that commite assigned to the development branch and still get the history.

ha How to do this?

    
asked by anonymous 25.01.2018 / 11:26

2 answers

0

From what I understand, I think you want this in your development branch:

--> C0 ---> C1 --> C1'
  • C0 is the commit before your
  • C1 is when you committed the change and showed it to the client
  • C1 'is when you reversed the change you made, but kept the history of what happened: you committed the C1 in develop.
  • Thus, it is better to use git revert passing the hash of commit C1:

    git revert 25d025e3317f59882d03b7938ee500e86d858c33
    

    To find the hash of the commit, use the following command:

    git log
    

    It will be the first record (bottom-up), similar to this: 25d025e3317f59882d03b7938ee500e86d858c33

    If you want to go back with the change after revert, use the same commit number to apply it again in your branch:

    git cherry-pick 25d025e3317f59882d03b7938ee500e86d858c33
    
        
    26.01.2018 / 15:17
    2

    One of the branch strategies is Feature branch, in which you develop each feature in a specific branch and then merge them into an integrating branch. The integration branch is what you are going to send to the release, so you only integrate the code when you are sure you will be entering the release.

    In addition to branch strategies, having a release plan is important, because when you are ready to deliver, you should have already been tested, deployed in an approval environment, and therefore your code will already be integrated into the integrative branch, which is the source of the continuous integration build.

    Another way for you to separate the features in delivery is to do with feature flag, so if the client does not approve at this point, the functionality is only turned off in an admin panel, but this technique is more complex and is used in large enterprise environments or in very complex software.

        
    26.01.2018 / 15:04