Jump to content
havchr

Looking for something like soft reset - keep all changes but in a new/clean branch.

Recommended Posts

I am sorry if this is in the wrong spot, and if my search/document reading skills were not good enough.

My problem that I am trying to solve is this

I have been working on a branch that has lived alongside main for quite a while - and my commits have been "exploratory".

In the git client that I used previously - I would sometimes do a soft reset, where I would keep all my changes, without any commits.

My main goal is to create a new branch from main , where I order my commits and changes now that I know where I am going. 
Lets say I have main , main/featureA_messyTask and now I want to create main/featureA and copy in all the changes as local changes, from featureA_messyTask but not the history.

Then I would order my commits in featureA so that they make sense to the code reviewer etc and finally merge in featureA into main.

 

I hope it was possible to understand what I am asking for and help me figure out how to do this. 

Very happy with Plastic so far - we are using it for gamedev and it handles big files very well.

 

Best regards.

Share this post


Link to post
Share on other sites

Hi,

If I properly understand you, you would like to somehow rewrite the repo history, right? I'm afraid it's not possible in Plastic. You can merge/cherry-pick changesets from one branch to another and even delete changesets but not rewrite a branch history.

Some details in the following links:

http://blog.plasticscm.com/2018/08/why-we-dont-delete-branches-in-plastic.html

https://medium.com/@psluaces/plasticscm-vs-git-c17934fad7ed

Quote

 

1) Branches in Git and Plastic are different. In Plastic, branches are containers, while in Git they are just pointers.

This means that in Git is very easy to lose where a commit came from, while in Plastic, changesets always belong to a single branch and their history is preserved.

 

 

Please let us know if it helps.

Regards,

Carlos.

Share this post


Link to post
Share on other sites

I don't need to rewrite the history - I can keep main/featureA_messyTask as a branch - I just want to create a new branch main/featureA - where I copy in the changes I did and organize my commits. I guess there is always the option of doing this manually using featureA_messyTask as a template/ for the changes I am putting into featureA.

 

My end goal is that someone further down the line who is looking at the history of a file - would see changes like this : 

"Added ability to test feature A directly by using the debug menu" -
and not stuff like "continuing working on messy feature" - with lots of changes to multiple files.

When I was working on the messy feature - I did not know exactly where I was going and what needed to change , and also I can sometimes be a bit messy in my programming whilst I'm exploring how to solve problems. 

 

Share this post


Link to post
Share on other sites
Quote

I don't need to rewrite the history - I can keep main/featureA_messyTask as a branch - I just want to create a new branch main/featureA - where I copy in the changes I did and organize my commits. I guess there is always the option of doing this manually using featureA_messyTask as a template/ for the changes I am putting into featureA.

You could merge the changes from "main/featureA_messyTask" to "main/featureA" and shelve the changes (or cherry-pick the specific changesets that are relevant for your task). Once you have the shelve, you can undo the changes in your workspace (including the merge link) and finally apply the shelve and checkin the relevant changes in different steps based on your needs.

Quote

 

My end goal is that someone further down the line who is looking at the history of a file - would see changes like this : 

"Added ability to test feature A directly by using the debug menu" -
and not stuff like "continuing working on messy feature" - with lots of changes to multiple files.

When I was working on the messy feature - I did not know exactly where I was going and what needed to change , and also I can sometimes be a bit messy in my programming whilst I'm exploring how to solve problems. 

 

But note that if you check the file revision history, it will also include the changes performed in "main/featureA_messyTask". This is what I meant with you cannot rewrite the history.

Regards,

Carlos.

Share this post


Link to post
Share on other sites

Thanks - that seems like a workflow which would work for my use-case. However, since we are using plastic cloud - I can't use shelving . 

I'll reapply my changes manually for now. Which can also be a step where code quality can improve, because I'm now recreating/reintroducing the end result while knowing where I am going. 

But when shelving gets supported for cloud I'll try it out :)

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...