What is the easiest way to push a very messy local git repo to a remote git repo, chunk by chunk?

StackOverflow https://stackoverflow.com/questions/21452934

  •  04-10-2022
  •  | 
  •  

Question

I have forked and then cloned a git repo that my research group is working on a while ago. I was (and still am) new to git, but I happily created a few branches, occasionally merging them with the changes from the remote source. I have also pushed my changes every now and again to my remote forked version of the repo, but I never pushed much to the original repo, because my work was undone and nobody demanded it.

Here is the situation: I have a whole load of changes committed and pushed to my remote repo. Almost none of it made it to the original remote repo that the rest of the group is working on. Just doing one big diff is out of the question, because there is still way too much scruffy unfinished work that nobody besides me might need. How do I start pushing selected changes (as in, selected manually, by hand) to the remote repo, chunk by chunk?

I am not fluent in git, and I wonder if I have to make a clean clone and start from there. Is there a smarter way of approaching my situation?

Thank you.

Was it helpful?

Solution

git cherry-pick can work. The interactive solution (other than using gui tools, of which there are many) is to use interactive add. This technique is powerful and allows you to do all the work in a single commit, fairly easily.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top