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.

11 comments:

Unknown said...

How to invest in mutual funds online in India?

Walmart-Flipkart: Ready to enter the Food and Grocery Sector, Together

Silent is another face of Violence

Ethereum

Which will climb the $500 ladder first
Zcash or Litecoin?


What is your advice for a 20 year old who wants to start...

Suruchi Pandey said...

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

instaacoders said...

Best Enterprise Solution in Noida, Delhi
Best Email Marketing Services in Delhi
Top SEO Company in Delhi, Noida, India
Digital Marketing Company in Delhi
Best Graphic Design Company Delhi, India
Ui/Ux Design Service | Ui/Ux Design and Development Services
Best Responsive Web Design Services India
Best Website Design Company Delhi, Noida
Node Js Development Company in India
Best Angular Js Web Development Company in Delhi, Noida

Azure DevOps said...

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

Appsinvo - Mobile App Development Company said...

Thank you for your post. This is useful information. !!!

Mobile App Development Company in India
Top Mobile App Development Company in India
Mobile App Development Company
Mobile App development company in Asia
Mobile App Consultant
https://www.appsinvo.com/

Anu said...

I seriouѕly love your site.. Pleasant colors & theme.
DevOps Training in Bangalore | Certification | Online Training Course institute | DevOps Training in Hyderabad | Certification | Online Training Course institute | DevOps Training in Coimbatore | Certification | Online Training Course institute | DevOps Online Training | Certification | Devops Training Online

Sajjad Ahmed said...
This comment has been removed by the author.
Lillian J. Turner said...

Nice Blog. Thanks for sharing with us. Such amazing information.

How to Turn your Shopping Store Interesting

MyBlogger Club

Guest Posting Site

Best Guest Blogging Site

Guest Blogger

Guest Blogging Site

Anisha said...

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

Anisha said...

CLASS III DIGITAL SIGNATURE CERTIFICATE a Great article

Ebizfiling India Pvt Ltd said...

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?"