Reputation: 2443
My branch is behind by origin by 5 commits.
muralish@vnc9[~/git/task](task-68↓3| ✓)$git status
# On branch task-68
# Your branch is behind 'origin/task-68' by 5 commits, and can be fast-forwarded.
#
nothing to commit, working directory clean
muralish@vnc9[~/git/task](desflow-68↓3| ✓)$
These commits are A-> B-> C -> D ->E. How can I get only the changes related to commit C to the working directory.
It tried git rebase -i but won't list that commit at all. It outputs the below informarion.
noop
# Rebase 484a22b..b7fa802 onto 484a22b
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop f
Any help is appreciated.
Upvotes: 0
Views: 316
Reputation: 34024
Try
git cherry-pick <C-sha>
If you don't want these changes to be stored as a new commit use
git reset HEAD~1
The changes will then be neither staged nor committed.
Update:
If you want your own branch to appear to have merged those 5 commits from task-68 while in reality it would have only commit C you can write (after cherry-picking):
git merge -s ours task-68
Update-2:
It is a common practice to keep your local task-68
branch identical to origin/task-68
, so if you want to omit some commits from the parent branch, it is a good idea to fork it beforehand:
git checkout -b task-68-wip
After this, proceed with cherry-picking and merging as described above.
Upvotes: 1