user7693832
user7693832

Reputation: 6849

How to pull remote repo only get its last commit in Git?

In this below scenario:

enter image description here

In the remote repo there is a dev branch, and in my local repo there have a dev branch too.

I have a requirement, I want to pull the remote_repo dev to my local repo dev branch, but only want to last commit, I mean the commit:20190906.

How to do with that?

Upvotes: 1

Views: 30

Answers (1)

VonC
VonC

Reputation: 1323125

You can use git cherry-pick:

git checkout dev
git fetch
git cherry-pick origin/dev # last commit only

But you then need to decide what to do with your local branch dev: do you (force) push it back to origin? That would override the history of dev on origin.

Upvotes: 1

Related Questions