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.
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.
Just like git push --force allows overwriting remote branches, git fetch --force (or git pull --force ) allows overwriting local branches.
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.
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 .
You need to specify the remote name because it is equal to origin
by default
git reset --hard upstream/master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With