Tuesday, June 06, 2017

Github, Git, Git Extensions, using Git, Git Tips and Tricks, Git for Windows

Git Tutorial #1 - Reset current branch to delete local commits with no data loss, and replace with 1 better remote commit

When you are working on a project thats undergoing changes so rapidly that you have no chance to do milestones or take breaks to put out stable versions, you should still commit LOCALLY (Commit, not Commit&Push) often to back up your work, and have old code to go back to during troubleshooting. Taking the time is annoying so just write as little description as possible to save time. 
Then after you have gotten to a milestone or a stable point, you can throw all those away, and Commit and Push ONE single solid commit with complete description and thought put into it when you have time.
This is best to do with local commits only, otherwise there can be some weird situations.
I mean you can do it, but its bad practice to change the history.

Step 1 - Highlight the last commit you want to keep.



Step 2 - Right click on it and choose Reset current branch to here.



Step 3 - This is where you make important decisions. In this tutorial we want to leave our files unchanged, and just delete the commit indexes.



Step 4 - Now it will show the last commit as the past one you picked, and that "New" files can be committed. Still no file data has changed.  At this point you want to the final Commit, and (most likely Push to github too).



Step 5 - You see you've effectively turned all the junk into 1 well formatted commit.


Can the text/descriptions for the old ones can be copied to the new text? No. There is no easy way to aggregate them all like some other git merge commands do. This is why I said dont put that much effort into the temp names. You could copy/paste em manually if it was that important.

12 comments:

  1. Great deal of information provided by you. I found the information very helpful and informative both for newbies as well as experienced ones.
    Thank you for sharing such useful details.
    Web Design Company | Web development Lucknow

    ReplyDelete
  2. Super collection thanks for sharing and keep update.
    DevOps Online Training

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. Annual Company Compliance Lite nice and informative post thanks for the update
    Our Annual Company Compliance Lite package includes all forms applicable to a Company. Including forms AOC-4, MGT-7, ADT-1, and DIR-3 KYC

    ReplyDelete
  5. Annual returns must be filed with the ROC by every company and Limited Liability Partnership. Every piece of information, from the selection of the directors or managing directors to the company's dissolution, must be given to the ROC (Registrar of Companies). Before learning about the ROC annual filing of a company, let's get some beneficial information about "What is ROC?"

    ReplyDelete
  6. This comment has been removed by the author.

    ReplyDelete