0

I have some local changes in my local repo (in my computer) which i dont want to commit. Now i am going to take a pull request from my master repo but it says, "Please, commit your changes or stash them before you can merge".

So how can I force git to update my local repo by override those local changes when take a pull request?

edi9999
  • 19,701
  • 13
  • 88
  • 127
Harshana
  • 7,297
  • 25
  • 99
  • 173
  • 1
    It's not clear what you're trying to achieve - if you don't want to commit them, and you want those changes to be overwritten and lost, why not just reset/checkout locally before pulling? If you want to keep the changes and then apply them afterwards, use stash... – Jon Skeet Sep 18 '15 at 05:52
  • reset/checkout locally means manually delete my changes in order to sync with master? even after that since my local file has been changed, git might tell me to do a commit – Harshana Sep 18 '15 at 05:58
  • No, it means use "git checkout" or "git reset" to get *git* to undo your local changes. – Jon Skeet Sep 18 '15 at 05:59
  • ok thanks. i have did a git hard reset. Btw what is the difference of git checkout and reset – Harshana Sep 18 '15 at 07:05
  • I would suggest reading the documentation very carefully :) – Jon Skeet Sep 18 '15 at 07:13

1 Answers1

1

You have two options:

  1. If you want to drop your changes completely that you've worked on since your last commit, do a

    git reset HEAD --hard

    Be aware that you can't undo that command

  2. You can also stash does changes (eg put them in a location to reuse later, but this will never be shared when you push/pull)

    git stash

    And if you want to apply (recover) the latest stash, you can do

    git stash pop

I'd rather go with 2., so that you don't loose your changes in case you need them later.

You would do :

git stash
git pull <remote> <branch>
edi9999
  • 19,701
  • 13
  • 88
  • 127