How can I pull from a branch to start fetching on a specific commit?
Suppose, I have these branches:
branch1
and oldbranch1
branch1
is the rollback version of oldbranch1
And suppose, oldbranch1
have these commits:
somebranch
to oldbranch1
)And on branch1
:
Now I want to get the updates from oldbranch1
skipping the commit_3
from oldbranch1
as it contains wrong merges that deletes the changes from commit_2
and commit_1
How can I do it? is there any magic commands for this?
Skipping a commit means mainly a git rebase --interactive
:
tmp
branch on top of oldbranch1
(git branch
tmp oldbranch1
)rebase -i branch1
that tmp
branch, replaying each commit except commit3
that you can dropreset --hard
branch1
to the new tmp
HEAD.The last step means: moving (forcing) branch1
HEAD to tmp
, but since the rebase only added new (rewritten) commits to branch1
, you should be able to simply do:
git checkout branch1
git merge tmp
That should make a fast-forward merge of tmp
to branch1
, moving simply branch1
HEAD to where tmp
is.
Then a simple git push
(or git push -u origin branch1
if branch1
was never pushed before) will be enough.