![]() ![]() cherry-picking means to copy over from a different branch.rebasing works on commits present in your current branch.you can do so while immediately checking out that commit as well.you can just force a branch to point to a different commit.reset will make your branch point to a different commit (-hard also checks out the previous commit, -soft keeps added files in the index (that would be committed if you commit again) and the default (-mixed) will not check out the previous commit (wiping your local changes) but it will clear the index (nothing has been added for commit yet).But in this way you can keep an up-to-date modified (patched) version that is based on your distribution's version while your actual development is against the real upstream master. Alternatively you could just generate a diff and then apply it outside of any Git source tree. It seems a reasonably convenient way to base your development on the "real" upstream master while using a different "downstream" master to check whether your local changes also still apply to that. That would remove previously-cherry-picked commits from the current duplicate, and just re-apply all of the changes happening in "topic" on top of your current "dump" (different ancestor). When your topic-duplicate branch has been checked out. So the entire sequence will come down to: git reset -hard Rebasing only works on a branch that already has the commits, so you need to duplicate your topic branch each time you want to do that.Ĭherrypicking is much easier: git cherry-pick master.topic ![]() What I am trying to say is that if you want to update the current "duplicate" branch based off of a different ancestor you must first delete the previously "cherrypicked" commits by doing a git reset -hard or git branch -f topic_duplicate and then copying the other commits over (from the main topic branch) by either rebasing or cherry-picking. Perhaps you could also just cherry-pick after clearing the current "topic_duplicate". Or just by discarding the dump git branch -D dump Or with git branch -M topic_duplicate dump You could then replace "dump" with "topic_duplicate" by doing: git branch -f dump topic_duplicate ![]() So your changes since master are now reapplied on top of "dump" but the result ends up in "topic_duplicate". Now your changes are reapplied in branch topic_duplicate based on the starting point of "dump" but only the commits that have happened since "master". Git rebase -onto dump master topic_duplicate You will now create a duplicate of your topic branch and then rebase it onto the source code dump that is sitting in branch "dump": git branch topic_duplicate topic You now have a branch in which you have applied changes, let's call it "topic". Suppose you have a branch that is disconnected from master because you have taken sources from some other location and dumped it into the branch. This would be a programmatic way to remove commits from a branch, for instance, in order to copy new commits to it (using rebase). In fact, if you don't care about checking out, you can set the branch to whatever you want with: git branch -f For your reference, I believe you can "hard cut" commits out of your current branch not only with git reset -hard, but also with the following command: git checkout -B
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |