Search code examples
gitrepositoryputtygit-bashgit-commit

Ignore Git commits when pull. Skip commits and continue from latest commit


I pushed the code twice on my repo and pulled it on the server, It had some issues so I had to go back and hard reset to a previous commit. Can I only get changes from last commit ?

Command I used to go back to commit 'C'

git reset --hard C

Visual representation:

commits on repo:

A-B-C-D-E-F

git on server side:

A-B-C'

Locally I only want to push some changes that are in commit 'F'. Now i want to pull changes only from the commit 'F' and skip 'D,E'. On server it tells me I am three commits behind and when I pull it gets files from all the commits. I only want files updated in 'F' commit or any other latest commit.

(Sorry for bad english)


Solution

  • To pull changes from F git cherry-pick origin/F then you need to push out your new changes. git push -f origin. This will remove D and E from your branch on the server side.