0

I have one new staged file A on branch branch_A. There are some changes in other files as well on branch_A.

I want to create a new branch - branch_B and move file A to branch_B without moving changes in other files on branch_A.

Is that possible? If so - how?

zwolin
  • 974
  • 3
  • 9
  • 19
  • 3
    Possible duplicate of [How do you merge selective files with git-merge?](http://stackoverflow.com/questions/449541/how-do-you-merge-selective-files-with-git-merge) – Padhraic Apr 22 '16 at 15:26
  • I don't understand how this is a duplicate. There is only one answer there (6-th from the top) that answers my question and this is by a coincidence. Moreover - OP asked quite a different question. If you still insist - feel free to do whatever you want with my question. – zwolin Apr 25 '16 at 13:27

1 Answers1

1

Start by creating the new brunch

git branch branch_B

Then move the file using git stash. if you want to stash a single file you can do the following:

git add myFileToMove
git stash --keep-index

If you have not made the commit yet, just run git stash. This will save away all of your changes. Switch to branch_B and run git stash pop.

Stefano
  • 3,981
  • 8
  • 36
  • 66