Need help cleaning up git repository
dufault at hda.com
dufault at hda.com
Thu Nov 5 15:51:07 UTC 2020
> On Nov 5, 2020, at 09:40 , Jan.Sommer at dlr.de wrote:
> Ok, I hope I understand everything correctly.
> Still, best to make a local copy of your repository directory.
I shall do that.
>> You can see that my master is ahead of origin/master, and my local branches
>> that I'd like to clean up (e.g. mvme5500-final, atsam-fixes) also include those
>> I think I want to do something like:
>> - Rename my local master branch to a branch name that is related to the
>> changes I put in;
> # Create a new branch from your local master branch under a new name
> $ git branch NewBranchName master
> # Reset the local master branch to be in line with origin/master (your changes will still be in NewBranchName)
> $ git checkout master
> $ git reset --hard origin/master
This sounds straight-forward.
>> - Drop the changes I made that on that branch in the other branches, e.g
>> mvme5500-final, atsam-fixes etc so that those branches are now based on
>> origin/master and only have the changes related to what I was working on.
> You might achieve that with a rebase in the respective branch, e.g. for mvme5500-final:
> $ git checkout mvme5500-final
> $ git rebase -i origin/master
> This should open a terminal with all commits in this branch since origin/master with the oldest commit at the top.
> Simply, delete the full lines of all the commits you don't want to keep in the branch, i.e. the one from your old master, save and close.
> If you are lucky and no conflicts appear, you end up with a branch which is based on origin/master with only the commits you want.
> Another option would be to create a new branch based on origin master and cherry-pick the commits you want to keep from mvme5500-final using git cherry-pick.
> $ git branch mvme5500-new mvme5500-final
> $ git checkout mvme5500-new
> # Cherry-pick a single commit
> $ git cherry-pick <commit hash>
> # Cherry-pick a set of continuous commits
> § git cherry-pick <first commit>~..<last commit> # make sure to have the "~" after the first hash
> That's what I could come up with so far.
I'll try your first suggestion "rebase in the respective branch".
"mvme5500-final" has too many changes to submit in one chunk. Next I'll need to figure out the best way to split those up into manageable, reviewable pieces.
HD Associates, Inc. Software and System Engineering
This email is delivered through the public internet using protocols subject to interception and tampering.
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 235 bytes
Desc: Message signed with OpenPGP
More information about the users