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?
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
You can simply remove that file from the commit you are cherry picking if it is not required...
git rm file_name
git commit
-here make sure that your commit message contains Change ID : line as a last paragraph
git push origin HEAD:refs/for/branch_name
This way you will not get any conflicts and it wil make your merge easier next time..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With