git cherry-pick merge deleting file

cherry-pick, git

Solution

https://www.kernel.org/pub/software/scm/git/docs/git-cherry-pick.html

Cherry-pick creates new commit, so if you omit file that does not exist in your branch but exists in a branch you are going to merge in eventually nothing will happen.

mkdir test && cd test && git init && touch foo.txt
git add foo.txt && git commit -m "Init repo"
git branch test && git checkout test && vi foo.txt 
git add foo.txt && git commit -m "Changed foo on branch test"
git checkout master && touch bar.txt
git add bar.txt && git commit -m "Create bar.txt"
vi bar.txt 
touch baz.txt && git add . && git commit -m "Will be cherry picked"
git checkout test && git cherry-pick bfd1b58
git rm bar.txt && git commit
git checkout master && git merge test

And as a result of `ls`: `bar.txt baz.txt foo.txt`

Problem

I'm trying to cherry-pick a commit in git, which adds a bunch of files, but also modifies a file that doesn't yet exist in my branch. There is a conflict where the files to add are all staged, and the file that was changed in the commit but doesn't yet exist in the branch is not staged and and is listed as: ``` deleted by us: app/changed_file.rb ``` If I just commit the staged files, will that cause issues when the `changed_file.rb` is eventually merged into the branch?

Original source