#How can I achieve this with GIT?

1 messages · Page 1 of 1 (latest)

sharp wraith
#

I have a co-worker that has made many unrelated changes to our code base and commited them all in one commit.

Luckily he's done this on a new branch, but I'd like to take all of his changes and just "unstage" them and start over commiting these changes properly.

Can I do this with GIT?

#

One way I've thought about doing this is cloning the repo twice, creating a new branch on one and cloning his branch on another. Then I'd remove all but the .git directory in mine and copy all his files over to mine without his .git directory.

#

but if there is an easier way to do this, please let me know.

teal dagger
#

if the changes are not pushed you could just reset to head

sharp wraith
#

they're pushed but not merged into main

teal dagger
#

believe you can force push to rewrite history, but it could introduce conflicts

#

maybe it's just easier to accept it was all done in one commit this time and let it be a learning lesson for him

sharp wraith
#

Perhaps 😄

teal dagger
# sharp wraith Perhaps 😄

sorry just got back to this

couldn't you just reset head, checkout a new branch, commit things individually and push? then delete the remote branch that had it all in one commit

#

resetting head should just unstage, and then checking out would still leave the edits in unstaged

sharp wraith
#

I guess I can try that, I don't usually do much with GIT on the CLI.

teal dagger
#

it can be done via a GUI too

#

usually i dont suggest AI, but im pretty sure chatgpt is good at git suggestions as its ancient and lots of information on it that it has gathered

#

would pretty much tell you exactly what to do