Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git - How to force pull from an upstream remote and ignore commits in your local and remote?

Tags:

git

github

I want to pull from from an upstream branch and I want to ignore all commits made by me in my local and my remote on git. I only want the changes from the upstream remote.

I am having issues with:

git pull upstream master

And I do not want to manually merge them. I just want to ignore all my local changes and the above command to work.

I tried:

git reset --hard

But that doesn't seem to work for me. I want the changes from the upstream.

like image 991
Yathi Avatar asked Aug 27 '14 04:08

Yathi


People also ask

How do I discard local changes in git and pull from remote?

There are two Git commands a developer must use in order to discard all local changes in Git, remove all uncommited changes and revert their Git working tree back to the state it was in when the last commit took place. The commands to discard all local changes in Git are: git reset –hard. git clean -fxd.

Will git pull override my local changes?

Just like git push --force allows overwriting remote branches, git fetch --force (or git pull --force ) allows overwriting local branches.

How do I force git to pull a file?

git pull --force it feels like it would help to overwrite local changes. instead, it fetches forcefully but does not merge forcefully ( git pull --force = git fetch --force + git merge ). Like git push, git fetch allows us to specify which local and remote branch we want to work on.

How do I pull a specific commit from a remote?

The short answer is: you cannot pull a specific commit from a remote. However, you may fetch new data from the remote and then use git-checkout COMMIT_ID to view the code at the COMMIT_ID .


1 Answers

You need to specify the remote name because it is equal to origin by default

git reset --hard upstream/master
like image 58
ДМИТРИЙ МАЛИКОВ Avatar answered Sep 22 '22 02:09

ДМИТРИЙ МАЛИКОВ