Git switch to master and bring irreproducible files along

While I was working on feature_branch, I ended up fixing a bug for the whole site. I want to fix the bug fix, not my feature_branch. The fix involves adding some new files, so when I try to check the wizard, it interrupts and warns me that the files will be overwritten without a trace.

How can I switch to the wizard and bring irreproducible files with me?

+5
source share
3 answers

Something is wrong. Usually, when you switch branches, unprocessed files are listed with you without any notice. That is why they are called "without a trace." However, you say files without a trace will be overwritten. This means that you created an unconventional file in a new branch that already exists in the main branch. This means that you need to decide what you want to do: what you need to save. It's not about getting git to do something; it's a matter of when you don't understand what you want.

Assuming you want to somehow resolve the conflict between two copies of the same file, you can do

git checkout feature_branch
git stash
git checkout master
git stash pop

And then eliminate the conflicts that arise.

+17
source

, , .

  • , , .
  • git stash save "bug fix for master"
  • git checkout master
  • git stash pop
  • ,
+3

The simplest solution I can think of is to make a local copy of your unplayable / modified files. Then check your wizard and run it and add a commit. If there is any conflict, git will notify you, and you can merge at this point.

0
source

All Articles