0

I have a project managed with git with multiple active branches. e.g. feature1, feature2, feature3,..., master

I was working feature1: I have created files, made modifications, committed and pushed my changes to remote feature1.

Now I have realized one of the modifications (edited file x.x) on this branch would be very useful on feature2 as well. However, if I checkout feature2 x.x is not there so I can not commit it in this branch.

What is the clean way to get x.x on feature2, without having to merge feature1 into feature2?

00__00__00
  • 4,834
  • 9
  • 41
  • 89

1 Answers1

2

If you only want the single file, you can do git checkout feature1 -- x.x This will just bring the file as is from that branch and keep you your current branch.

One thing to watch for with doing things like this is that it can cause some issues with merging your branches as you will have two separate commits making changes to the same location of a file. This isn't a big deal just something to watch for.

Schleis
  • 41,516
  • 7
  • 68
  • 87