Git cherry-pick
I am new to git and I understand how git cherry-pick works, but here is my problem:
Recently, someone on my team changed the directory structure in master, but not the directory structure in another branch.
Now when I commit changes to my code in a branch, I want to bring them (cherry-picked) to master. This was fine as long as the directory structures in both the master and the branch were the same.
topDir / some / subdir / file - master
topDir / some / other / subdir / file - branch
whose changes are to be made to master are the same, but not the directory structure in which it is contained. When I try to cherry-pick the normal way I get an error: / p>
git checkout master git commit cherry error: pathspec topDir / some / other / subdir / file does not exist
Now what is the best way to do cherry picking in this scenario? Any pointers are much appreciated.
OK. I just noticed that in the same scenario, when I make a cherry pick, git is smart enough to pick one of the files correctly from the commit, but doesn't recognize the other.
To use the same example I mentioned in my original post: TOPDIR / some / subdirectory / file1, TOPDIR / some / subdir1 / file2.
I go to the master, which has "file1" and "file2", only in a different structure: TOPDIR / SRC / some / subdirectory / file1 TOPDIR / SRC / some / subdir1 / file2.
Now, if I cherry-pick, git is smart enough to pick up the changes in file1 even if it's in a different dir structure, but it doesn't display the changes for file2. Any pointers? If anyone wants me to be clearer, I would be glad.
So what I did to fix this was make a cherry pick, manually change the one that git didn't pick, and git commit -C.
source to share
Happy to help :) if one of the masters is persistent, I would fix the file structure in the theme branch to match the master, commit the branch, * then merge the changes into master, not cherry-picked, As in
git checkout branch
mv other/subdir/file subdir/file
git status
// git add and git rm to get the commit proper
git commit -m "fixing file struct"
git checkout master
git merge branch
Indeed, it depends on what file use cases are and what you want to be on the master branch, which is much more important for your company, not so much a technical problem that all users can answer you;)
source to share