0

I'm still learning the ropes with Git, so forgive me if this is a straight forward solution.

I started off with 1 file, but I needed to make changes based on 2 separate JIRA tickets. I made the changes and pushed up the code on one ticket. Now, for my other ticket, it doesn't show any changes because it was all done in the first ticket. Is it possible to move the code changes from one push to another, or would I have to grab an older version of the code and start over, making the changes and pushing 1 ticket at a time?

helloworld95
  • 366
  • 7
  • 17
  • Generally you cannot change commits once you have pushed them to a central server. – mkrieger1 Jun 17 '20 at 16:39
  • Maybe you can associate the same Git commit with more than one Jira ticket. I can't tell you how, because I don't know how Jira works. – mkrieger1 Jun 17 '20 at 16:40
  • @mkrieger1 Thanks for your quick comments! Unfortunately we don't want to have 1 commit link to multiple tickets. We want to have 1 commit and ultimately 1 pull request per ticket – helloworld95 Jun 17 '20 at 16:43
  • Then you need to create another commit and I'm not sure what exactly you are asking. – mkrieger1 Jun 17 '20 at 16:48
  • The first commit+push had 100% of the code changes. But, I wanted 50% on the first commit+push and 50% on the second commit+push. Is there a way to move that 50% from the first commit+push over to another one? Or would I have to grab old code and push one at a time? Hopefully this makes more sense – helloworld95 Jun 17 '20 at 16:51
  • See https://stackoverflow.com/questions/6217156/break-a-previous-commit-into-multiple-commits. But note that once you have pushed a commit to a shared central repository you cannot change it anymore without disrupting the workflow for your colleagues. You could go back and recreate the work you have done, this time creating two separate commits. This part of your history would then be duplicated. – mkrieger1 Jun 17 '20 at 16:53
  • Thanks for the link. I think I will have to recreate my work. Splitting commits is one thing, but it looks like splitting code pushes is either not possible or highly unrecommended. Thanks for your help! – helloworld95 Jun 17 '20 at 17:07
  • @mkrieger1 as an inviolable rule in git, there is no way to change the content of a commit without destroying the commit. It wouldn't be much of a versioning system otherwise. – Daemon Painter Jun 17 '20 at 19:09

0 Answers0